Battleships Update

I’ve been rather obsessively working on my Battleships program the last few days, and have quite a bit to show for it: The autosolver works now, as does the random puzzle generator. The random puzzle generator is nowhere near as speedy or elegant as the one in Fathom It!, but it’s a start.

For the autosolver, I spent the better part of a programming day working on a blind alley of an approach, placing the 4-ship, then the 3-ships, and so on. I’m not sure where the algorithm went awry, but it consistently failed to work as expected. Then it occurred to me to simply solve the puzzles in a brute force variation of what I use on the harder puzzles:

  • Fill in the easy cells.
  • For the first empty cell, create a test version where it’s a ship, and another where it’s water.
  • Repeat these steps for each of the two test versions.
  • Repeat until all test versions have been completed or ruled out.

I use a List of possible solutions, creating a second List by iterating through the first one, then copying the second List back to the first one and repeating.

Now that the autosolver works, I’m now thinking about adding a puzzle designer so the user can design, test, and save their own puzzles (although I think I’m going to first take some time off from this project to get some other things done).

Advertisements
This entry was posted in Battleships, C#, Grid-based and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s