示例#1
0
文件: WhiteKing.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.E1 && to == Board.G1 &&
         board.Status.WhiteCouldCastleShort &&//check if the king or the rook didn't already move 
         board.IsPathClear(Board.E1, Board.H1) &&// check if the path is clear 
         !board.IsAttackedByBlack(Board.E1) && !board.IsAttackedByBlack(Board.F1) && !board.IsAttackedByBlack(Board.G1)// check if the squares traversed by king are not attacked
         );
 }
 /// <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.E1 && to == Board.G1 &&
         board.Status.WhiteCouldCastleShort &&                                                                          //check if the king or the rook didn't already move
         board.IsPathClear(Board.E1, Board.H1) &&                                                                       // check if the path is clear
         !board.IsAttackedByBlack(Board.E1) && !board.IsAttackedByBlack(Board.F1) && !board.IsAttackedByBlack(Board.G1) // check if the squares traversed by king are not attacked
         );
 }