SOLVED:: Another Knotch on Elysia's belt
Thanks to whoever reads this and spends their time answering.
I'm building what I thought would be a quick sudoku generator / solver / allows the user to play it. I didn't realize how deep the logic of this particular puzzle game goes. I'll leave out most of the code and try to explain design first.
3 Classes
Sudoku
Board
Space
Each class privately owns the class below it.
Sudoku Possesses 10 Board classes. I declared these Boards in an Array:
Code:
Board GameBoard[10];
The reasoning for this was to make many states of how the puzzle is being solved in one declaration. Allowing for the user to undo while playing the game by copying to current state from previous state. Board[9] is future (aka solved), Board[8] is Present, and any Board[7] - Board[0] is a state of the past.
I finished the Random Generation algorythym and it works everytime. So my next step is to remove numbers while keeping it solvable. I added:
Code:
void Copy(Board Copyfrom, Board Copyto);
in the Sudoku class. Before I moved any further I wanted to test this function so I copied my Solved Board over to a new blank Board and displayed the board copied to rather than the solved Board. To my surprise it showed up blank still. Somehow my data is not transfering over. My concern is there is some inaccuracy with passing an array through funcations considering Copy is taking two class arrays as input and copying 2d int array values from one to the other.
I noticed during the randomgeneration phase, as well, that if I generated numbers into an array it gave very linear results. Example:
Code:
int temp[3];
temp[0] = (rand()%9)+1; // number value for the space
temp[1] = (rand()%9); // row of the space
temp[2] = (rand()%9); // column of the space
This when placed in a loop would keep generating random numbers on a linear diagnol of the board. Once finished with one diagnol it would move to another.
If I changed nothing else in my program except:
Code:
int tempnumber, tempr, tempc;
tempnumber = (rand()%9)+1; // number value for the space
tempr = (rand()%9); // row of the space
tempc = (rand()%9); // column of the space
Sudenly the random numbers actually appeared random. This is starting to make me fear that there are rules to arrays that I know know about. Thank you to anyone who can shed some light on this.