internal Board(string fen) : this() { byte num1 = 0; byte num2 = 0; this.WhiteCastled = true; this.BlackCastled = true; byte num3 = 0; this.WhoseMove = ChessPieceColor.White; if (fen.Contains("a3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)40; } else if (fen.Contains("b3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)41; } else if (fen.Contains("c3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)42; } else if (fen.Contains("d3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)43; } else if (fen.Contains("e3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)44; } else if (fen.Contains("f3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)45; } else if (fen.Contains("g3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)46; } else if (fen.Contains("h3")) { this.EnPassantColor = ChessPieceColor.White; this.EnPassantPosition = (byte)47; } if (fen.Contains("a6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)16; } else if (fen.Contains("b6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)17; } else if (fen.Contains("c6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)18; } else if (fen.Contains("d6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)19; } else if (fen.Contains("e6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)20; } else if (fen.Contains("f6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)21; } else if (fen.Contains("g6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)22; } else if (fen.Contains("h6")) { this.EnPassantColor = ChessPieceColor.Black; this.EnPassantPosition = (byte)23; } if (fen.Contains(" w ")) { this.WhoseMove = ChessPieceColor.White; } if (fen.Contains(" b ")) { this.WhoseMove = ChessPieceColor.Black; } foreach (char ch in fen) { if ((int)num1 < 64 && (int)num2 == 0) { if ((int)ch == 49 && (int)num1 < 63) { ++num1; } else if ((int)ch == 50 && (int)num1 < 62) { num1 += (byte)2; } else if ((int)ch == 51 && (int)num1 < 61) { num1 += (byte)3; } else if ((int)ch == 52 && (int)num1 < 60) { num1 += (byte)4; } else if ((int)ch == 53 && (int)num1 < 59) { num1 += (byte)5; } else if ((int)ch == 54 && (int)num1 < 58) { num1 += (byte)6; } else if ((int)ch == 55 && (int)num1 < 57) { num1 += (byte)7; } else if ((int)ch == 56 && (int)num1 < 56) { num1 += (byte)8; } else if ((int)ch == 80) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Pawn, ChessPieceColor.White); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 78) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Knight, ChessPieceColor.White); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 66) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Bishop, ChessPieceColor.White); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 82) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Rook, ChessPieceColor.White); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 81) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Queen, ChessPieceColor.White); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 75) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.King, ChessPieceColor.White); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 112) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Pawn, ChessPieceColor.Black); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 110) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Knight, ChessPieceColor.Black); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 98) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Bishop, ChessPieceColor.Black); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 114) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Rook, ChessPieceColor.Black); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 113) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.Queen, ChessPieceColor.Black); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch == 107) { this.Squares[(int)num1].Piece = new Piece(ChessPieceType.King, ChessPieceColor.Black); this.Squares[(int)num1].Piece.Moved = true; ++num1; } else if ((int)ch != 47 && (int)ch == 32) { ++num2; } } else if ((int)ch == 75) { if (this.Squares[60].Piece != null && this.Squares[60].Piece.PieceType == ChessPieceType.King) { this.Squares[60].Piece.Moved = false; } if (this.Squares[63].Piece != null && this.Squares[63].Piece.PieceType == ChessPieceType.Rook) { this.Squares[63].Piece.Moved = false; } this.WhiteCastled = false; } else if ((int)ch == 81) { if (this.Squares[60].Piece != null && this.Squares[60].Piece.PieceType == ChessPieceType.King) { this.Squares[60].Piece.Moved = false; } if (this.Squares[56].Piece != null && this.Squares[56].Piece.PieceType == ChessPieceType.Rook) { this.Squares[56].Piece.Moved = false; } this.WhiteCastled = false; } else if ((int)ch == 107) { if (this.Squares[4].Piece != null && this.Squares[4].Piece.PieceType == ChessPieceType.King) { this.Squares[4].Piece.Moved = false; } if (this.Squares[7].Piece != null && this.Squares[7].Piece.PieceType == ChessPieceType.Rook) { this.Squares[7].Piece.Moved = false; } this.BlackCastled = false; } else if ((int)ch == 113) { if (this.Squares[4].Piece != null && this.Squares[4].Piece.PieceType == ChessPieceType.King) { this.Squares[4].Piece.Moved = false; } if (this.Squares[0].Piece != null && this.Squares[0].Piece.PieceType == ChessPieceType.Rook) { this.Squares[0].Piece.Moved = false; } this.BlackCastled = false; } else if ((int)ch == 32) { ++num3; } else if ((int)ch == 49 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 1); } else if ((int)ch == 50 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 2); } else if ((int)ch == 51 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 3); } else if ((int)ch == 52 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 4); } else if ((int)ch == 53 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 5); } else if ((int)ch == 54 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 6); } else if ((int)ch == 55 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 7); } else if ((int)ch == 56 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 8); } else if ((int)ch == 57 && (int)num3 == 4) { this.FiftyMove = (byte)((int)this.FiftyMove * 10 + 9); } else if ((int)ch == 48 && (int)num3 == 4) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 0); } else if ((int)ch == 49 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 1); } else if ((int)ch == 50 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 2); } else if ((int)ch == 51 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 3); } else if ((int)ch == 52 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 4); } else if ((int)ch == 53 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 5); } else if ((int)ch == 54 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 6); } else if ((int)ch == 55 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 7); } else if ((int)ch == 56 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 8); } else if ((int)ch == 57 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 9); } else if ((int)ch == 48 && (int)num3 == 5) { this.MoveCount = (int)(byte)(this.MoveCount * 10 + 0); } } Zobrist.InitiateZobristTable(); this.ZobristHash = Zobrist.CalculateZobristHash(this); }