public Engine() { // create all classes bitboard = new BitBoard(); magicMoves = new MagicMoves(); transpositionTable = new TranspositionTable(); pawnEvalTT = new PawnsTT(); evalTT = new EvalTT(); board = new Board(true); evaluator = new My_Evaluator(); moveGenerator = new MoveGenerator(); searchMove = new SearchMove(); attack = new Attack(); // Setup dependency : assign pointers to classes SetupClassDependency(); searchMove.SearchMoveHasNewResults = StoreCurrentEngineResults; SetupInitialBoard(true); MoveHistory = new Move[100]; }
public void LoadFrom(Board clone) { // load the entire contents from a clone magicMoves = clone.magicMoves; transpositionTable = clone.transpositionTable; evaluator = clone.evaluator; ClearBoard(); moveGenerator = clone.moveGenerator; // pieces = new ulong[clone.pieces.Length]; for (int i = 0; i < clone.pieces.Length; i++) pieces[i] = clone.pieces[i]; allPiecesBB = clone.allPiecesBB; for (int i = 0; i < Const.NrColors; i++) for (int j = 0; j < Const.NrPieceTypes; j++) pieceBB[i, j] = clone.pieceBB[i, j]; // PiecePos for (int i = 0; i < Const.NrColors; i++) for (int j = 0; j < Const.NrPieceTypes; j++) for (int k = 0; k < Const.MaxNrPiecesPerType; k++) PiecePos[i, j, k] = clone.PiecePos[i, j, k]; //.. // nrPieces for (int i = 0; i < Const.NrColors; i++) { TotalNrPieces[i] = clone.TotalNrPieces[i]; for (int j = 0; j < Const.NrPieceTypes; j++) NrPieces[i, j] = clone.NrPieces[i, j]; } // SquareContents for (int i = 0; i < Const.NrSquares; i++) SquareContents[i] = clone.SquareContents[i]; // // state of the game info colorToMove = clone.colorToMove; enemyColor = clone.enemyColor; for (int i = 0; i < Const.NrColors; i++) { canCastleKingSide[i] = clone.canCastleKingSide[i]; canCastleQueenSide[i] = clone.canCastleQueenSide[i]; hasCastled[i] = clone.hasCastled[i]; } // .. enPassantPosition = clone.enPassantPosition; // halfMoveNr = clone.halfMoveNr; fiftyMoveNr = clone.fiftyMoveNr; capturedPiecePosition = clone.capturedPiecePosition; capturedPieceType = clone.capturedPieceType; repeatedPosition_SearchOffset = clone.repeatedPosition_SearchOffset; // maxNrStoredBoardStates = clone.maxNrStoredBoardStates; nrStoredBoardStates = clone.nrStoredBoardStates; storedBoardStates = new BoardState[clone.storedBoardStates.Length]; for (int i = 0; i < clone.storedBoardStates.Length; i++) storedBoardStates[i] = clone.storedBoardStates[i]; // HashValue = clone.HashValue; bwPawnsHashValue = clone.bwPawnsHashValue; for (int i = 0; i < Const.NrColors; i++) { StaticMaterialScore[i] = clone.StaticMaterialScore[i]; StaticPositionalScore[i] = clone.StaticPositionalScore[i]; } // nrHashValuesInHistory = clone.nrHashValuesInHistory; HashValueHistory = new ulong[clone.HashValueHistory.Length]; for (int i = 0; i < clone.HashValueHistory.Length; i++) HashValueHistory[i] = clone.HashValueHistory[i]; }