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.
Each class privately owns the class below it.
Sudoku Possesses 10 Board classes. I declared these Boards in an Array:
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 is future (aka solved), Board is Present, and any Board - Board is a state of the past.Code:Board GameBoard;
I finished the Random Generation algorythym and it works everytime. So my next step is to remove numbers while keeping it solvable. I added:
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.Code:void Copy(Board Copyfrom, Board Copyto);
I noticed during the randomgeneration phase, as well, that if I generated numbers into an array it gave very linear results. Example:
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.Code:int temp; temp = (rand()%9)+1; // number value for the space temp = (rand()%9); // row of the space temp = (rand()%9); // column of the space
If I changed nothing else in my program except:
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.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