Sunday, December 13, 2009

Step 2


Step 2
Originally uploaded by dima.barashkov
Set up simple solving logic of setting Cell's values and eliminating row/column candidates when a value is set.

Onto group logic.
First step would be to make a simple algorithm for generating possible group solutions. Ex. a 2-count group of "5+" would be either 1+4, or 2+3, or a 3-count group of "7+" would be 1+2+4, or 1+3+3.

  • since the number of parts to split a sum(or other action) is variable - have a List of possibles initialized to 1
  • the order is irrelevant so far, so a 1,3,2 solution values is same as 3,2,1
  • for addition, while the sum of parts is less than needed value
  • increment last most value by one, and check if it fits
  • when value has reached to highest board allowed values' transitions should follow like so: On a board size 4 when going from (1,2,4) next should be (1,3,3)

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.

Overlay


Overlay
Originally uploaded by dima.barashkov
In white are the drawn-recognized characters from within a cell.

Now I am ready to actually write the game-solving logic with the cells, underlying groups and math functions that each group has to satisfy.

Everyday Genius



Originally uploaded by dima.barashkov
Progress: Cells are parsed out of the screenshot into their own images. Next up to convert them to b/w image and run the connected shapes algorithm (which has already proven to work). The results of the connected-shapes would be saved for each new unknown character to server as a baseline for recognition.
After that onto the actual game-solving logic.

Tuesday, December 8, 2009

Writing a solver for Everyday Genius : Square logic (http://store.steampowered.com/app/32150). First things first -- image recognition of the game board to figure out what numbers are being used.
I am using a 3rd party connected components c# class that gives me a "connected component" in a list of vertical "spanned" lines that it appears on.

CodeBlocks