I am programming a simple algorithm for chess AI (minimax). I have a functions that takes a list of possible moves and returning a score for the best move in a current state (taking into account the board state). I want to add a way to check if a current board state is already seen (I don't need nor want to save all the already seen boards, just to know if the current board already seen and what the assigned value was, something like a hash code). In general, I want a way to to assign a code (again, like a hash code) for a class (that contains multiple properties, both value and refence type) and then save this code for future checks.
I emphasizes, I don't want to check only the board/class reference but I want to check the board/class content.
this is a board class:
public class ChessBoard
{
public Piece[,] board; //Piece as a class as well
public PieceColor myColor; //enum
public PieceColor opColor; //enum
public DateTime lastMoveTime;
public TimeSpan myTimer;
public TimeSpan opTimer;
public GameState currentTurn; //enum
public int enPassantCol = -1;
public bool whiteShortCastleFlag = true;
public bool whiteLongCastleFlag = true;
public bool blackShortCastleFlag = true;
public bool blackLongCastleFlag = true;
//more nonrelevant fields, constructors and logic
}
the board Piece array can be checked by the references. no need to check Piece content (that means, if all the elements in Piece[,] array points to the same references, this is ok, all the Pieces content stay the same, they are just moving in the board array).
Thank you.