예제 #1
0
파일: Piece.cs 프로젝트: vegah/Nostradamus
 public virtual void Move(NormalMove m)
 {
     if (m.Capture!=null)
         Board.RemovePiece(m.To,m.Capture);
     Board.RemovePiece(m.From, this);
     Board.SetPiece(m.To,this);
     Moves.Add(m);
 }
예제 #2
0
파일: Piece.cs 프로젝트: vegah/Nostradamus
 public virtual NormalMove IsLegalMove(NormalMove normalMove, int ply)
 {
     foreach (var m in CalculateAllMoves(ply))
     {
         if (normalMove == m)
             return m;
     }
     return null;
 }
예제 #3
0
파일: Piece.cs 프로젝트: vegah/Nostradamus
 public virtual void UndoMove(NormalMove m)
 {
     Board.RemovePiece(m.To, this);
     if (m.Capture != null)
     {
         Board.SetPiece(m.To,m.Capture);
     }
     Board.SetPiece(m.From,this);
     Moves.Remove(m);
     undoedMoves.Add(m);
 }
예제 #4
0
파일: Pawn.cs 프로젝트: vegah/Nostradamus
 public override void Move(NormalMove m)
 {
     var enpassant = m as EnPassantMove;
     if (enpassant != null)
     {
         Moves.Add(m);
         Board.SetPiece(m.To,m.Piece);
         Board.RemovePiece(m.From,m.Piece);
         Board.RemovePiece(m.Capture.Square,m.Capture);
     }
     else
         base.Move(m);
 }
예제 #5
0
 public int Perft(int depth,Color color, NormalMove lastmove=null)
 {
     if (depth == 0)
     {
         Log.Debug($"Came from {lastmove}");
         return 0;
     }
     var clock = new Stopwatch();
     clock.Start();
     var allValidMoves = _board.GetAllMovesFor(color,depth).ToList();
     var subMoves = 0;
     foreach (var move in allValidMoves)
     {
         move.Do();
         subMoves+=Perft(depth-1,ColorHelper.Reverse(color),move);
         move.Undo();
     }
     clock.Stop();
     if (depth>4)
         Log.Info($"Depth {depth} took {clock.ElapsedMilliseconds}.  Looked at {lastmove} {allValidMoves.Count} moves, which resulted in {subMoves} submoves");
     return allValidMoves.Count+subMoves;
 }
예제 #6
0
파일: King.cs 프로젝트: vegah/Nostradamus
 public override void UndoMove(NormalMove m)
 {
     var castling = m as CastlingMove;
     if (castling != null)
     {
         UndoCastle(castling);
     }
     else
         base.UndoMove(m);
 }
예제 #7
0
 // Supposed to check for checks and other stuff.
 private NormalMove IsLegalMove(NormalMove normalMove)
 {
     // uh-oh
     var correctMove = normalMove.Piece.IsLegalMove(normalMove,_currentPly);
     if (normalMove.Piece.Color==ToMove && correctMove!=null)
         return correctMove;
     return null;
 }