예제 #1
0
파일: Game.cs 프로젝트: Squomp/Chess960
        /// <summary>
        ///   Start a new game from the specified FEN string position. For internal use only.
        /// </summary>
        /// <param name="fenString"> The str fen. </param>
        private static void NewInternal(string fenString)
        {
            if (fenString == string.Empty)
            {
                if (!Is960)
                {
                    fenString = Fen.GameStartPosition;
                }
                else
                {
                    fenString = Fen.GameStartPosition960;
                }
            }

            Fen.Validate(fenString);

            HashTable.Clear();
            HashTablePawn.Clear();
            HashTableCheck.Clear();
            KillerMoves.Clear();
            HistoryHeuristic.Clear();

            UndoAllMovesInternal();
            MoveRedoList.Clear();
            saveGameFileName = string.Empty;
            Fen.SetBoardPosition(fenString);
            PlayerWhite.Clock.Reset();
            PlayerBlack.Clock.Reset();
        }
예제 #2
0
        public void SameKillerMoveWithHigherScoreReplacesSlotEntry()
        {
            const int Ply = 10;

            KillerMoves.Clear();

            Piece     piece     = new Piece();
            PiecePawn piecePawn = new PiecePawn(piece);

            piece.Top = piecePawn;

            Move move1 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(0), Board.GetSquare(1), null, 0, 20);

            // Add a move
            KillerMoves.RecordPossibleKillerMove(Ply, move1);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move1);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply).Score == 20);
            Assert.IsNull(KillerMoves.RetrieveB(Ply));

            // Add same move AGAIN, but with higher score. Move should be replaced, using higher score.
            Move move2 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(0), Board.GetSquare(1), null, 0, 30);

            KillerMoves.RecordPossibleKillerMove(Ply, move2);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move2);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply).Score == 30);
            Assert.IsNull(KillerMoves.RetrieveB(Ply));

            // Add same move AGAIN, but with LOWER score. No killer moves should be changed
            Move move3 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(0), Board.GetSquare(1), null, 0, 10);

            KillerMoves.RecordPossibleKillerMove(Ply, move3);
            Assert.IsTrue(Move.MovesMatch(KillerMoves.RetrieveA(Ply), move2));
            Assert.IsTrue(KillerMoves.RetrieveA(Ply).Score == 30);
            Assert.IsNull(KillerMoves.RetrieveB(Ply));

            // Now add a different move, and check it goes in slot B
            Move move4 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(2), Board.GetSquare(3), null, 0, 5);

            KillerMoves.RecordPossibleKillerMove(Ply, move4);
            Assert.IsTrue(Move.MovesMatch(KillerMoves.RetrieveA(Ply), move3));
            Assert.IsTrue(KillerMoves.RetrieveA(Ply).Score == 30);
            Assert.IsTrue(Move.MovesMatch(KillerMoves.RetrieveB(Ply), move4));
            Assert.IsTrue(KillerMoves.RetrieveB(Ply).Score == 5);

            // Now improve score of the move that is in slot B.
            // Slot B's score should be updated. Slot A should stay the same.
            // Slot's A & B should be SWAPPED.
            Move move5 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(2), Board.GetSquare(3), null, 0, 100);

            KillerMoves.RecordPossibleKillerMove(Ply, move5);
            Assert.IsTrue(Move.MovesMatch(KillerMoves.RetrieveA(Ply), move5));
            Assert.IsTrue(KillerMoves.RetrieveA(Ply).Score == 100);
            Assert.IsTrue(Move.MovesMatch(KillerMoves.RetrieveB(Ply), move3));
            Assert.IsTrue(KillerMoves.RetrieveB(Ply).Score == 30);
        }
예제 #3
0
        public void RecordPossibleKillerMoveTest()
        {
            int Ply = 10;

            KillerMoves.Clear();

            Piece     piece     = new Piece();
            PiecePawn piecePawn = new PiecePawn(piece);

            piece.Top = piecePawn;

            Move move1 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(0), Board.GetSquare(1), null, 0, 20);

            KillerMoves.RecordPossibleKillerMove(Ply, move1);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move1);
            Assert.IsNull(KillerMoves.RetrieveB(Ply));

            Move move2 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(2), Board.GetSquare(3), null, 0, 10);

            KillerMoves.RecordPossibleKillerMove(Ply, move2);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move1);
            Assert.IsTrue(KillerMoves.RetrieveB(Ply) == move2);

            Move move3 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(4), Board.GetSquare(5), null, 0, 15);

            KillerMoves.RecordPossibleKillerMove(Ply, move3);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move1);
            Assert.IsTrue(KillerMoves.RetrieveB(Ply) == move3);

            Move move4 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(6), Board.GetSquare(7), null, 0, 30);

            KillerMoves.RecordPossibleKillerMove(Ply, move4);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move4);
            Assert.IsTrue(KillerMoves.RetrieveB(Ply) == move1);

            // Start again
            KillerMoves.Clear();

            Move move5 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(16), Board.GetSquare(17), null, 0, 200);

            KillerMoves.RecordPossibleKillerMove(Ply, move5);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move5);
            Assert.IsNull(KillerMoves.RetrieveB(Ply));

            Move move6 = new Move(0, 0, Move.MoveNames.Standard, piece, Board.GetSquare(18), Board.GetSquare(19), null, 0, 300);

            KillerMoves.RecordPossibleKillerMove(Ply, move6);
            Assert.IsTrue(KillerMoves.RetrieveA(Ply) == move6);
            Assert.IsTrue(KillerMoves.RetrieveB(Ply) == move5);
        }