static int GetCaptureCastlingMask(int captureSquare, CastlingAvail status) { switch (captureSquare) { case Square.a1: return(MovePackHelper.GetCastlingMerge((int)(status & CastlingAvail.QueenSideWhite))); case Square.h1: return(MovePackHelper.GetCastlingMerge((int)(status & CastlingAvail.KingSideWhite))); case Square.a8: return(MovePackHelper.GetCastlingMerge((int)(status & CastlingAvail.QueenSideBlack))); case Square.h8: return(MovePackHelper.GetCastlingMerge((int)(status & CastlingAvail.KingSideBlack))); } return(0); }
public void SetBoard(string fen) { ZKey = 0; if (fen == null) { throw new ArgumentNullException("fen"); } InitPieceList(); ClearBoard(); string[] fenParts = fen.Trim().Split(' '); whiteMaterialValue = 0; blackMaterialValue = 0; movesCount = 0; CastlingStatus = CastlingAvail.None; if (fenParts.Length != 6) { throw new Exception("Invalid fen:" + fen); } ParseParts(fenParts[0]); ParseToMove(fenParts[1]); ParseCastling(fenParts[2]); ParseEnPassant(fenParts[3]); if (false == int.TryParse(fenParts[4], out halfMoves)) { throw new Exception("Half moves count cannot be parsed:" + fenParts[4]); } if (false == int.TryParse(fenParts[5], out movesCount)) { throw new Exception("Moves count cannot be parsed:" + fenParts[5]); } if (movesCount < 1) { throw new Exception("Moves count less than 1:" + fenParts[5]); } }