I have the following in my program:
public static GameBoard possibleStates(GameBoard GameState, int turn)
{
printGameBoard(GameState); //getting what is passed in here
int innerCounter = 0;
int outerCounter = 0;
while(outerCounter < 3)
{
while(innerCounter < 3)
{
if(GameState.Board[outerCounter][innerCounter].isEmpty())
{
GameBoard PossibleBoard = new GameBoard();
PossibleBoard.Copy(GameState);
PossibleBoard.Board[outerCounter][innerCounter].ModifyOccupy(move); //the problem is here, changes to possibleboard are also reflected in gamestate
GameState.AddToActions(PossibleBoard);
}
innerCounter++;
}
innerCounter = 0;
outerCounter++;
}
return GameState;
}
My problem is that changing one, alters the value of another. I know it's because they are referencing the same space in memory, I just can't figure out how to not make them do that. I have already tried using the Copy method, and Clone method for my GameBoard class and they have not made any difference.