Wednesday, December 9, 2009

Preliminary algorithm/brainstorming.
A main Board class consisting of
  • Array of Cells
  • List of CellGroups
Array of Cells
  • each item in this 2D array would represent each cell of the game
  • has a solution value (or blank if one is not found yet)
  • has a list of possible solution values
List of CellGroups
  • A cell group represents a collection of cells that amount to the group's value based on the action described. ex. 5+ would mean that this Cell-Group individual values should add up to 5
  • a list of Cell references. ex. a particular CellGroup is including Cells[1,1] and [1,2]
  • this class would most likely include most of the game-solving logic.
Preliminary solution logic. I think I will employ something that resembles a "queue" here (//toexplain). Rough logic steps for first few hundred puzzle boards (that are granted to be very simple) in priority order from highest to lowest...
  • Cell's possible-solution contains only one item or Cell text value contains a "=" then set the Cell's solution value
  • Cell's possible-solution contains only one item from the Cell-Groups possible solution values then set the Cell's solution value
Hah! pretty simple to start out with, I think.
Keeping in mind the most general rule of this number game - one unique number per row and column no matter the cell-group rules -- the "queue" I mentioned will work something like this
  • Anytime a Cell's solution value is set, queue up a possible solution value eliminating method from all cells in the same row and column
  • From the bullet above any time a Cell is down to one possible solution value queue up a Cell's solution value to be set... naturally resolving in a recursive loop.

1 comment:

CodeBlocks