I can post more code if I need to, but before that I would like to just ask a general question about the following method in which an array is passed, and then set to another array, but for some reason the original array, the one being passed in, is also getting changed, how this possible/what should i do? Thanks
tempBoard is an array of same size as currentState, and temp[k] contains the changes that are being made in movePiece, current state is declared in the method and is not a global variable
private int[][] MiniMaxBaseCase(int[][] currentState, int currentColor)
{
tempBoard = movePiece(currentState,temp[k]);
}
private int[][] movePiece(int[][] currentState, int[] move)
{
if(move[0] == -1)
return currentState;
//if the piece is just moving
if(move[4] == -1)
{
currentState[move[2]][move[3]] = currentState[move[0]][move[1]];
currentState[move[0]][move[1]] = 0;
return currentState;
}
//if the piece is jumping another
if(move[4] != -1)
{
currentState[move[4]][move[5]] = currentState[move[0]][move[1]];
currentState[move[2]][move[3]] = 0;
currentState[move[0]][move[1]] = 0;
return currentState;
}
return currentState;
}