For the moment I'm strictly speaking in Pseudocode. I'd only like to see if i'm on the right track. The game I'm talking about is similar to a application called FLOW.
In this game, you're given a nxn board(Always a square) and need to fill out each slot in the board. Similarly, when a board game is initialized, it will have objects like the set up below...
Board - 1 2 3 1
0 0 0 0
0 2 3 0
0 0 0 0
In this example - the objects are 1 2 and 3.
A solution would be as follows...
Board - 1 2 3 1
1 2 3 1
1 2 3 1
1 1 1 1
The whole purpose is to fill out the board game by connecting the starting object to the end object. What I have in mind is the following...
CheckSolution(1d representation of the boards state, int totalcolors) {
// I would loop through the colors, a 0 is not a color - empty.
// If the board has a 0 in the array, I would automatically return a false solution.
// Then, I would call DepthFirstSearch on the color.
// -- I would set a counter on this to count the # of colors, if this isn't equal to the total # of that particular color, I would return false.
// Else, the solution is valid.
}
Does this sound reasonable? Or is the better way to implement a solution checker.
1 . . . 2 3 . . . 3 . . . . 2 1
appears to have two solutions with a flood fill approach but likely only has one valid solution.1 1 1 1 2 3 1 1 2 3 1 1 2 2 2 1
is not a valid solution which would be accepted as such by your approach. (the proper solution is1 1 1 1 2 3 3 1 2 3 3 1 2 2 2 1
)