示例#1
0
 public void ChangeEvaluator(Evaluator evaluator)
 {
     // call, if the evaluator is changed mid-games. Might give problems with TakeBack() !
      // change the evaluator of other classes.
      SetupClassDependency();
      // reset the static and material & postional score
      for (int color = 0; color < Const.NrColors; color++)
      {
     int material = 0;
     int positional = 0;
     for (int pieceType = 0; pieceType < Const.NrPieceTypes; pieceType++)
     {
        material += board.NrPieces[color, pieceType] * evaluator.PieceValues[pieceType];
        for (int j = 0; j < board.NrPieces[color, pieceType]; j++)
        {
           int position = board.PiecePos[color, pieceType, j];
           positional += evaluator.PieceSquareValues[color][pieceType][position];
        }
     }
     board.StaticMaterialScore[color] = material;
     board.StaticPositionalScore[color] = positional;
      }
 }
示例#2
0
        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];
        }
示例#3
0
 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];
 }