コード例 #1
0
 /// <summary>
 /// Verifies if the king can castle short.
 /// </summary>
 /// <param name="board">The board</param>
 /// <param name="from">The starting square</param>
 /// <param name="to">The ending square</param>
 /// <returns></returns>
 public bool CanCastleShort(Board board, int from, int to)
 {
     return(
         from == Board.E8 && to == Board.G8 &&
         board.Status.BlackCouldCastleShort &&                                                                          //check if the king or the rook didn't already move
         board.IsPathClear(Board.E8, Board.H8) &&                                                                       // check if the path is clear
         !board.IsAttackedByWhite(Board.E8) && !board.IsAttackedByWhite(Board.F8) && !board.IsAttackedByWhite(Board.G8) // check if the squares traversed by king are not attacked
         );
 }
コード例 #2
0
ファイル: BlackKing.cs プロジェクト: vgichar/shah
 /// <summary>
 /// Verifies if the king can castle short.
 /// </summary>
 /// <param name="board">The board</param>
 /// <param name="from">The starting square</param>
 /// <param name="to">The ending square</param>
 /// <returns></returns>
 public bool CanCastleShort(Board board, int from, int to)
 {
     return (
         from == Board.E8 && to == Board.G8 &&
         board.Status.BlackCouldCastleShort &&//check if the king or the rook didn't already move
         board.IsPathClear(Board.E8, Board.H8) &&// check if the path is clear
         !board.IsAttackedByWhite(Board.E8) && !board.IsAttackedByWhite(Board.F8) && !board.IsAttackedByWhite(Board.G8)// check if the squares traversed by king are not attacked
         );
 }