The following has to do with programming. It's not really a general programming question, and it pertains to a specific YPP puzzle, so I stuck it here.
I've been poking around with Carpentry for a while now, and I've come to the point where I need to write an algorithm to solve the puzzle. I know it sounds like I've done nothing, but there's more: I've read a single space in the carpentry puzzle (one area where you need to patch up) and determined what is a space that needs filling, and what is a space that needs filling and can have a piece placed on it successfully, for lack of a better name I refer to them as "corner" pieces. The "pieces" are divided into small squares that when put together form a carpentry piece, again for lack of a better name I call these "bits."
Since I'm not sure I've explained it well enough here's a picture of the bot's debug visual:
Blue denotes a "corner" bit and white is a bit that is not filled, and not a corner. A few of them you might notice aren't completely white although they should be. This is not the fault of the board reading but the way I visualize it (it's just colored squares on top of each other so they overlap causing the wrong color to show occasionally).
Here's where the algorithm specific things start (I assume, I'm still rather new to algorithms for puzzle solving). I've read in the board successfully, and now I attempt to solve the board by iterating through each "bit." If the bit is a "corner" bit then I attempt to fit in a puzzle piece that is presently in the toolbox by checking the area of each piece and seeing if the spots are all unfilled, if they are I move on to another variation of the piece (flips/rotations) and if that fails again I move on to another piece before attempting to place pieces in another bit of the board. Currently I have only one piece (the fatter one that's really easy to work with as a human) that I've coded in but I can already see this growing into a tremendously slow process. Initially reading the single zone of the carp board takes around 2-4 seconds on my laptop, and an additional 0.5-1.5 seconds to re-check the board for any changes to it. I can only imagine what iterating through each bit and each piece's variation would do to performance. Ignoring performance however, I've found that this would easily lead to gaps in the board, so my second pass at the idea is to attempt to fit as many bits from a piece into the board's corner bits as possible, which I think might help but I've yet to attempt anything. I feel like I'm going about this all wrong, any input is appreciated. I'd really love a point in the right direction or a jumping off point (maybe some puzzle solving article you read somewhere?) for this. Thanks!
I've been poking around with Carpentry for a while now, and I've come to the point where I need to write an algorithm to solve the puzzle. I know it sounds like I've done nothing, but there's more: I've read a single space in the carpentry puzzle (one area where you need to patch up) and determined what is a space that needs filling, and what is a space that needs filling and can have a piece placed on it successfully, for lack of a better name I refer to them as "corner" pieces. The "pieces" are divided into small squares that when put together form a carpentry piece, again for lack of a better name I call these "bits."
Since I'm not sure I've explained it well enough here's a picture of the bot's debug visual:
Blue denotes a "corner" bit and white is a bit that is not filled, and not a corner. A few of them you might notice aren't completely white although they should be. This is not the fault of the board reading but the way I visualize it (it's just colored squares on top of each other so they overlap causing the wrong color to show occasionally).
Here's where the algorithm specific things start (I assume, I'm still rather new to algorithms for puzzle solving). I've read in the board successfully, and now I attempt to solve the board by iterating through each "bit." If the bit is a "corner" bit then I attempt to fit in a puzzle piece that is presently in the toolbox by checking the area of each piece and seeing if the spots are all unfilled, if they are I move on to another variation of the piece (flips/rotations) and if that fails again I move on to another piece before attempting to place pieces in another bit of the board. Currently I have only one piece (the fatter one that's really easy to work with as a human) that I've coded in but I can already see this growing into a tremendously slow process. Initially reading the single zone of the carp board takes around 2-4 seconds on my laptop, and an additional 0.5-1.5 seconds to re-check the board for any changes to it. I can only imagine what iterating through each bit and each piece's variation would do to performance. Ignoring performance however, I've found that this would easily lead to gaps in the board, so my second pass at the idea is to attempt to fit as many bits from a piece into the board's corner bits as possible, which I think might help but I've yet to attempt anything. I feel like I'm going about this all wrong, any input is appreciated. I'd really love a point in the right direction or a jumping off point (maybe some puzzle solving article you read somewhere?) for this. Thanks!
Comment