示例#1
0
        public void MakeNullMove()
        {
            IrrevState irrevState = GetIrrevState().CopyBeforeMove();

            IrrevStates.Add(irrevState);
            ChangeTurn();
            ZobristHashUtils.UpdateTurn(ref GetIrrevState().ZobristHash);
            irrevState.PliesFromNull = 0;
        }
示例#2
0
        public void Reset()
        {
            Pieces    = new ulong[2, 6];
            Occupancy = new ulong[2];
            IrrevState irrevState = new IrrevState(ZobristHashUtils);

            IrrevStates = new List <IrrevState>()
            {
                irrevState
            };
        }
示例#3
0
        public bool IsCheck()
        {
            IrrevState irrevState = GetIrrevState();

            if (irrevState.IsCheck == null)
            {
                ulong king = Pieces[Turn, (int)PieceType.King];
                irrevState.IsCheck = IsAttacked(Turn, king, false);
            }
            return(irrevState.IsCheck.Value);
        }
示例#4
0
        public bool IsThreefoldRepetition()
        {
            int        repetitions  = 0;
            IrrevState irrevState   = GetIrrevState();
            int        maxMovesBack = Math.Min(irrevState.HalfmoveClock, irrevState.PliesFromNull);
            int        lastMove     = Math.Max(IrrevStates.Count - 1 - maxMovesBack, 0);
            ulong      hash         = GetIrrevState().ZobristHash;

            for (int i = IrrevStates.Count - 5; i >= lastMove && repetitions < 2; i -= 2)
            {
                if (IrrevStates[i].ZobristHash == hash)
                {
                    repetitions++;
                }
            }
            return(repetitions == 2);
        }