//todo добавить на сервер ValidateMove, чтобы сначала вызвать его, потом клиентский Move, потом серверный Move public void Move(MoveContent move) { PlayerLock.GameLock = true; var primary = move.MovingPiecePrimary; OnlineManager.Move(primary.SrcPosition, primary.DstPosition, move.PawnPromotedTo); }
public ChessBoard(ChessBoard board) { Score = board.Score; EndGamePhase = board.EndGamePhase; WhoseMove = board.WhoseMove; MoveCount = board.MoveCount; FiftyMove = board.FiftyMove; RepeatedMove = board.RepeatedMove; blackCastled = board.blackCastled; blackInCheck = board.blackInCheck; blackInMate = board.blackInMate; whiteCastled = board.whiteCastled; whiteInCheck = board.whiteInCheck; whiteInMate = board.whiteInMate; staleMate = board.staleMate; EnPassantColor = board.EnPassantColor; EnPassantPosition = board.EnPassantPosition; InsufficientMaterial = board.InsufficientMaterial; LastMove = new MoveContent(board.LastMove); pieces = new ChessPiece[64]; for (byte x = 0; x < 64; ++x) { if (board.pieces[x] != null) { pieces[x] = new ChessPiece(board.pieces[x]); } } }
internal static ulong UpdateZobristHash(ulong hash, MoveContent move, ChessPieceColor whosMove, bool pawnPromote) { hash = Zobrist.GetHashResult((int)move.MovingPiecePrimary.SrcPosition, move.MovingPiecePrimary.PieceType, move.MovingPiecePrimary.PieceColor, hash); if (move.MovingPieceSecondary.PieceType != ChessPieceType.None) { hash = Zobrist.GetHashResult((int)move.MovingPieceSecondary.SrcPosition, move.MovingPieceSecondary.PieceType, move.MovingPieceSecondary.PieceColor, hash); hash = Zobrist.GetHashResult((int)move.MovingPieceSecondary.DstPosition, move.MovingPieceSecondary.PieceType, move.MovingPieceSecondary.PieceColor, hash); if (move.MovingPieceSecondary.PieceColor == ChessPieceColor.White) { hash ^= Zobrist.ZobristTable[770]; } else { hash ^= Zobrist.ZobristTable[771]; } } if (move.TakenPiece.PieceType != ChessPieceType.None) { hash = Zobrist.GetHashResult((int)move.TakenPiece.Position, move.TakenPiece.PieceType, move.TakenPiece.PieceColor, hash); } hash = !pawnPromote?Zobrist.GetHashResult((int)move.MovingPiecePrimary.DstPosition, move.MovingPiecePrimary.PieceType, move.MovingPiecePrimary.PieceColor, hash) : Zobrist.GetHashResult((int)move.MovingPiecePrimary.DstPosition, ChessPieceType.Queen, move.MovingPiecePrimary.PieceColor, hash); if (whosMove == ChessPieceColor.White) { hash ^= Zobrist.ZobristTable[769]; hash ^= Zobrist.ZobristTable[768]; } else { hash ^= Zobrist.ZobristTable[768]; hash ^= Zobrist.ZobristTable[769]; } return(hash); }
public MoveContent(MoveContent moveContent) { this.MovingPiecePrimary = new PieceMoving(moveContent.MovingPiecePrimary); this.MovingPieceSecondary = new PieceMoving(moveContent.MovingPieceSecondary); this.TakenPiece = new PieceTaken(moveContent.TakenPiece.PieceColor, moveContent.TakenPiece.PieceType, moveContent.TakenPiece.Moved, moveContent.TakenPiece.Position); this.EnPassantOccured = moveContent.EnPassantOccured; this.PawnPromotedTo = moveContent.PawnPromotedTo; }
public void Move(MoveContent move) { if (_chessState.Engine.CheckEndGame() != null) { return; } PlayerLock.GameLock = true; _chessState.MonoBehaviour.StartCoroutine(EngineMove()); }
private void OnlineManagerOnOnOpponentMove(Domain.MoveDescription move) { if (_chessState.Engine.WhoseMove == _chessState.PlayerColor) { Debug.LogError("Player move, but received event from server of opponent move"); return; } if (_chessState.Engine.IsValidMove(move.Primary.Src, move.Primary.Dst) && _chessState.Engine.MovePiece(move.Primary.Src, move.Primary.Dst)) { var pawnPromotion = move.PawnPromotion == FSharpOption <Domain.PieceType> .None ? ChessPieceType.None : EngineMappers.toEngineType.Invoke(move.PawnPromotion.Value); var secondaryMove = new PieceMoving { PieceType = ChessPieceType.None }; if (move.Secondary != FSharpOption <Domain.Move> .None) { var secondary = move.Secondary.Value; secondaryMove = new PieceMoving { PieceType = ChessPieceType.Bishop, SrcPosition = secondary.Src, DstPosition = secondary.Dst }; } var takenPiece = new PieceTaken { PieceType = ChessPieceType.None }; if (move.TakenPiecePos != FSharpOption <byte> .None) { var taken = move.TakenPiecePos.Value; takenPiece = new PieceTaken { PieceType = ChessPieceType.Bishop, Position = taken }; } var moveContent = new MoveContent { MovingPiecePrimary = new PieceMoving { SrcPosition = move.Primary.Src, DstPosition = move.Primary.Dst }, PawnPromotedTo = pawnPromotion, MovingPieceSecondary = secondaryMove, TakenPiece = takenPiece }; _chessState.Board.Move(moveContent); PlayerLock.GameLock = false; } else { Debug.LogError("Invalid move from server: " + FSharp.Json.Json.serialize(move)); } }
public IContentBuilder <T> Move(ContentReference destination) { foreach (var latest in Fixture.Latest) { var command = new MoveContent(latest, destination); var content = command.Execute(); Add(content); } return(new ContentBuilder <T>(Fixture, _contents)); }
//Copy Constructor internal Board(Board board) { Squares = new Square[64]; for (byte x = 0; x < 64; x++) { if (board.Squares[x].Piece != null) { Squares[x] = new Square(board.Squares[x].Piece); } } WhiteAttackBoard = new bool[64]; BlackAttackBoard = new bool[64]; for (byte x = 0; x < 64; x++) { WhiteAttackBoard[x] = board.WhiteAttackBoard[x]; BlackAttackBoard[x] = board.BlackAttackBoard[x]; } EndGamePhase = board.EndGamePhase; HalfMoveClock = board.HalfMoveClock; RepeatedMove = board.RepeatedMove; WhiteCastled = board.WhiteCastled; BlackCastled = board.BlackCastled; WhiteCanCastle = board.WhiteCanCastle; BlackCanCastle = board.BlackCanCastle; WhiteKingPosition = board.WhiteKingPosition; BlackKingPosition = board.BlackKingPosition; BlackCheck = board.BlackCheck; WhiteCheck = board.WhiteCheck; StaleMate = board.StaleMate; WhiteMate = board.WhiteMate; BlackMate = board.BlackMate; WhoseMove = board.WhoseMove; EnPassantPosition = board.EnPassantPosition; EnPassantColor = board.EnPassantColor; ZobristHash = board.ZobristHash; Score = board.Score; LastMove = new MoveContent(board.LastMove); MoveCount = board.MoveCount; }
internal Board() { this.Squares = new Square[64]; for (byte index = 0; (int)index < 64; ++index) { this.Squares[(int)index] = new Square(); } this.LastMove = new MoveContent(); this.BlackCanCastle = true; this.WhiteCanCastle = true; this.WhiteAttackBoard = new bool[64]; this.BlackAttackBoard = new bool[64]; }
static string MakeOpponentMove() { gameEngine.AiPonderMove(); MoveContent lastMove = gameEngine.GetMoveHistory().ToArray()[0]; var srcCol = (byte)(lastMove.MovingPiecePrimary.SrcPosition % 8); var srcRow = (byte)(lastMove.MovingPiecePrimary.SrcPosition / 8); var dstCol = (byte)(lastMove.MovingPiecePrimary.DstPosition % 8); var dstRow = (byte)(lastMove.MovingPiecePrimary.DstPosition / 8); return($"{GetColumn(srcCol)} {GetRow(srcRow)} -> {GetColumn(dstCol)} {GetRow(dstRow)}"); }
internal Board() { Squares = new Square[64]; for (byte i = 0; i < 64; i++) { Squares[i] = new Square(); } LastMove = new MoveContent(); BlackCanCastle = true; WhiteCanCastle = true; WhiteAttackBoard = new bool[64]; BlackAttackBoard = new bool[64]; }
private static string MakeEngineMove(Engine engine) { engine.AiPonderMove(); MoveContent lastMove = engine.GetMoveHistory().ToArray()[0]; string output; var sourceColumn = (byte)(lastMove.MovingPiecePrimary.SrcPosition % 8); var srcRow = (byte)(lastMove.MovingPiecePrimary.SrcPosition / 8); var destinationColumn = (byte)(lastMove.MovingPiecePrimary.DstPosition % 8); var destinationRow = (byte)(lastMove.MovingPiecePrimary.DstPosition / 8); output = sourceColumn.ToString() + srcRow.ToString() + destinationColumn.ToString() + destinationRow.ToString(); return(output); }
public void Move(MoveContent move) { if (move.TakenPiece.PieceType != ChessPieceType.None) { Destroy(move.TakenPiece.Position); } Move(move.MovingPiecePrimary); if (move.MovingPieceSecondary.PieceType != ChessPieceType.None) { Move(move.MovingPieceSecondary); } if (move.PawnPromotedTo != ChessPieceType.None) { ref var pos = ref _board[move.MovingPiecePrimary.DstPosition]; pos = BoardLoader.ReplacePiece(pos, move.PawnPromotedTo); pos.SetPosition(new Position(move.MovingPiecePrimary.DstPosition)); }
public void Move(MoveContent move) { if (_chessState.Engine.CheckEndGame() != null) { return; } //swap active color if (_chessState.PlayerColor == ChessPieceColor.Black) { _chessState.PlayerColor = ChessPieceColor.White; } else if (_chessState.PlayerColor == ChessPieceColor.White) { _chessState.PlayerColor = ChessPieceColor.Black; } _cameraManager.MoveOtherSide(); }
public static void EngineMove(ChessBoard board) { if (CheckForMate(board.WhoseMove, board)) { return; } System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); //If there is no playbook move search for the best move MoveContent bestMove = SearchMove.AlphaBetaRoot(board, Constants.ply); ChessEngine.MoveContent(board, bestMove.MovingPiecePrimary.SrcPosition, bestMove.MovingPiecePrimary.DstPosition, ChessPieceType.Queen); PieceValidMoves.GenerateValidMoves(board); Evaluation.EvaluateBoardScore(board); System.Diagnostics.Debug.WriteLine("Engine Move Time: " + watch.ElapsedTicks); }
public ChessBoard() { Score = 0; blackInCheck = false; blackInMate = false; whiteInCheck = false; whiteInMate = false; staleMate = false; FiftyMove = 0; RepeatedMove = 0; blackCastled = false; whiteCastled = false; EndGamePhase = false; MoveCount = 0; EnPassantPosition = 0; InsufficientMaterial = false; EnPassantColor = ChessPieceColor.White; WhoseMove = ChessPieceColor.White; LastMove = new MoveContent(); pieces = new ChessPiece[64]; }
internal Board(Board board) { this.Squares = new Square[64]; for (byte index = 0; (int)index < 64; ++index) { if (board.Squares[(int)index].Piece != null) { this.Squares[(int)index] = new Square(board.Squares[(int)index].Piece); } } this.WhiteAttackBoard = new bool[64]; this.BlackAttackBoard = new bool[64]; for (byte index = 0; (int)index < 64; ++index) { this.WhiteAttackBoard[(int)index] = board.WhiteAttackBoard[(int)index]; this.BlackAttackBoard[(int)index] = board.BlackAttackBoard[(int)index]; } this.EndGamePhase = board.EndGamePhase; this.FiftyMove = board.FiftyMove; this.RepeatedMove = board.RepeatedMove; this.WhiteCastled = board.WhiteCastled; this.BlackCastled = board.BlackCastled; this.WhiteCanCastle = board.WhiteCanCastle; this.BlackCanCastle = board.BlackCanCastle; this.WhiteKingPosition = board.WhiteKingPosition; this.BlackKingPosition = board.BlackKingPosition; this.BlackCheck = board.BlackCheck; this.WhiteCheck = board.WhiteCheck; this.StaleMate = board.StaleMate; this.WhiteMate = board.WhiteMate; this.BlackMate = board.BlackMate; this.WhoseMove = board.WhoseMove; this.EnPassantPosition = board.EnPassantPosition; this.EnPassantColor = board.EnPassantColor; this.ZobristHash = board.ZobristHash; this.Score = board.Score; this.LastMove = new MoveContent(board.LastMove); this.MoveCount = board.MoveCount; }
static void Main(string[] args) { using (new MPI.Environment(ref args)) { Intracommunicator comm = Communicator.world; if (comm.Rank == 0) { RunEngine(); for (int i = 1; i < comm.Size; i++) { comm.Send(new InterProcessData() { ShallQuit = true }, i, 0); } } else { PieceMoves.InitiateChessPieceMotion(); while (true) { var data = comm.Receive <InterProcessData>(0, 0); if (data.ShallQuit) { break; } MoveContent bestMove = Search.Execute(data.ExamineBoard, data.pos, data.depth, data.GameBook); comm.Send(bestMove, 0, 0); } } } }
private static void MakeEngineMove(Engine engine) { DateTime start = DateTime.Now; engine.AiPonderMove(); MoveContent lastMove = engine.GetMoveHistory().ToArray()[0]; string tmp = ""; var sourceColumn = (byte)(lastMove.MovingPiecePrimary.SrcPosition % 8); var srcRow = (byte)(8 - (lastMove.MovingPiecePrimary.SrcPosition / 8)); var destinationColumn = (byte)(lastMove.MovingPiecePrimary.DstPosition % 8); var destinationRow = (byte)(8 - (lastMove.MovingPiecePrimary.DstPosition / 8)); tmp += GetPgnMove(lastMove.MovingPiecePrimary.PieceType); if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Knight) { tmp += GetColumnFromInt(sourceColumn + 1); tmp += srcRow; } else if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Rook) { tmp += GetColumnFromInt(sourceColumn + 1); tmp += srcRow; } else if (lastMove.MovingPiecePrimary.PieceType == ChessPieceType.Pawn) { if (sourceColumn != destinationColumn) { tmp += GetColumnFromInt(sourceColumn + 1); } } if (lastMove.TakenPiece.PieceType != ChessPieceType.None) { tmp += "x"; } tmp += GetColumnFromInt(destinationColumn + 1); tmp += destinationRow; if (lastMove.PawnPromotedTo == ChessPieceType.Queen) { tmp += "=Q"; } else if (lastMove.PawnPromotedTo == ChessPieceType.Rook) { tmp += "=R"; } else if (lastMove.PawnPromotedTo == ChessPieceType.Knight) { tmp += "=K"; } else if (lastMove.PawnPromotedTo == ChessPieceType.Bishop) { tmp += "=B"; } DateTime end = DateTime.Now; TimeSpan ts = end - start; Console.Write(engine.PlyDepthReached + " "); int score = engine.GetScore(); if (score > 0) { score = score / 10; } Console.Write(score + " "); Console.Write(ts.Seconds * 100 + " "); Console.Write(engine.NodesSearched + engine.NodesQuiessence + " "); Console.Write(engine.PvLine); Console.WriteLine(); Console.Write("move "); Console.WriteLine(tmp); }
private void ProceedMove(MoveContent lastMove, string message) { if (lastMove.TakenPiece.PieceType.ToString() != "None") { var takenSrcCell = Extensions.FromPosition(lastMove.TakenPiece.Position); var takenPiece = board.AllCells[takenSrcCell.x, takenSrcCell.y].currentPiece; if (takenPiece != null) { message += Extensions.PieceToStr(takenPiece) + " взятие "; takenPiece.Kill(); } } if (lastMove.MovingPiecePrimary.PieceType.ToString() != "None") { var primarySrcCell = Extensions.FromPosition(lastMove.MovingPiecePrimary.SrcPosition); var primaryDstCell = Extensions.FromPosition(lastMove.MovingPiecePrimary.DstPosition); var piecePrimary = board.AllCells[primarySrcCell.x, primarySrcCell.y].currentPiece; if (piecePrimary != null) { if (lastMove.PawnPromotedTo == ChessPieceType.Queen) { message += " Pawn повышение Queen "; PromotePiece(piecePrimary as Pawn, board.AllCells[primaryDstCell.x, primaryDstCell.y], piecePrimary.mainColor, piecePrimary.mainColor == Color.black ? Colors.BlackPieces : Colors.WhitePieces); } else { piecePrimary.MovePieceToCell(board.AllCells[primaryDstCell.x, primaryDstCell.y]); SoundEvents.PlayMoveSound(); message += Extensions.PieceToStr(piecePrimary); } } else { Debug.Log("Piece not found and not created!"); } } if (lastMove.MovingPieceSecondary.PieceType.ToString() != "None") { var secondarySrcCell = Extensions.FromPosition(lastMove.MovingPieceSecondary.SrcPosition); var secondaryDstCell = Extensions.FromPosition(lastMove.MovingPieceSecondary.DstPosition); var pieceSecondary = board.AllCells[secondarySrcCell.x, secondarySrcCell.y].currentPiece; if (pieceSecondary != null) { message += " рокировка "; pieceSecondary.Place(board.AllCells[secondaryDstCell.x, secondaryDstCell.y]); SoundEvents.PlayMoveSound(); message += Extensions.PieceToStr(pieceSecondary); } else { var msg = "pieceSecondary not found!"; msg += " Src X " + secondarySrcCell.x + " Y " + secondarySrcCell.y; msg += " Dst X " + secondaryDstCell.x + " Y " + secondaryDstCell.y; Debug.LogError(msg); //StaticEvents.LogMsgEvent(msg, LogType.Exception); } } if (lastMove.EnPassantOccured) { message += " взятие на проходе "; } message += "\n" + lastMove.ToString(); StaticEvents.LogMsgEvent(message, LogType.Log); CheckMove(engine); SwitchSides(); }
public MoveContent(MoveContent moveContent) { MovingPiecePrimary = new PieceMoving(moveContent.MovingPiecePrimary); MovingPieceSecondary = new PieceMoving(moveContent.MovingPieceSecondary); TakenPiece = new PieceTaken(moveContent.TakenPiece.PieceColor, moveContent.TakenPiece.PieceType, moveContent.TakenPiece.Moved, moveContent.TakenPiece.Position); EnPassantOccured = moveContent.EnPassantOccured; PawnPromoted = moveContent.PawnPromoted; }
public MoveContent(string move) : this() { int col = -1; bool flag1 = false; bool flag2 = false; if (move.Contains("=Q")) { this.PawnPromotedTo = ChessPieceType.Queen; } else if (move.Contains("=N")) { this.PawnPromotedTo = ChessPieceType.Knight; } else if (move.Contains("=R")) { this.PawnPromotedTo = ChessPieceType.Rook; } else if (move.Contains("=B")) { this.PawnPromotedTo = ChessPieceType.Bishop; } foreach (char ch in move) { switch (ch) { case '{': flag1 = true; break; case '}': flag1 = false; break; default: if (!flag1) { if (this.MovingPiecePrimary.PieceType == ChessPieceType.None) { this.MovingPiecePrimary.PieceType = MoveContent.GetPieceType(ch); if (this.MovingPiecePrimary.PieceType == ChessPieceType.None) { this.MovingPiecePrimary.PieceType = ChessPieceType.Pawn; col = MoveContent.GetIntFromColumn(ch); break; } break; } if (col < 0) { col = MoveContent.GetIntFromColumn(ch); break; } if (col >= 0) { int num = int.Parse(ch.ToString()); if (!flag2) { this.MovingPiecePrimary.SrcPosition = MoveContent.GetBoardIndex(col, 8 - num); flag2 = true; } else { this.MovingPiecePrimary.DstPosition = MoveContent.GetBoardIndex(col, 8 - num); } col = -1; break; } break; } break; } } }
public new string ToString() { if (!string.IsNullOrEmpty(this.PgnMove)) { return(this.PgnMove); } byte num1 = (byte)((uint)this.MovingPiecePrimary.SrcPosition % 8U); byte num2 = (byte)(8 - (int)this.MovingPiecePrimary.SrcPosition / 8); byte num3 = (byte)((uint)this.MovingPiecePrimary.DstPosition % 8U); byte num4 = (byte)(8 - (int)this.MovingPiecePrimary.DstPosition / 8); if (this.MovingPieceSecondary.PieceType == ChessPieceType.Rook) { if (this.MovingPieceSecondary.PieceColor == ChessPieceColor.Black) { if ((int)this.MovingPieceSecondary.SrcPosition == 7) { this.PgnMove = this.PgnMove + "O-O"; } else if ((int)this.MovingPieceSecondary.SrcPosition == 0) { this.PgnMove = this.PgnMove + "O-O-O"; } } else if (this.MovingPieceSecondary.PieceColor == ChessPieceColor.White) { if ((int)this.MovingPieceSecondary.SrcPosition == 63) { this.PgnMove = this.PgnMove + "O-O"; } else if ((int)this.MovingPieceSecondary.SrcPosition == 56) { this.PgnMove = this.PgnMove + "O-O-O"; } } } else { this.PgnMove = this.PgnMove + MoveContent.GetPgnMove(this.MovingPiecePrimary.PieceType); switch (this.MovingPiecePrimary.PieceType) { case ChessPieceType.Rook: this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); this.PgnMove = this.PgnMove + (object)num2; break; case ChessPieceType.Knight: this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); this.PgnMove = this.PgnMove + (object)num2; break; case ChessPieceType.Pawn: if ((int)num1 != (int)num3) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } break; } if (this.TakenPiece.PieceType != ChessPieceType.None) { this.PgnMove = this.PgnMove + "x"; } this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num3); this.PgnMove = this.PgnMove + (object)num4; if (this.PawnPromotedTo == ChessPieceType.Queen) { this.PgnMove = this.PgnMove + "=Q"; } else if (this.PawnPromotedTo == ChessPieceType.Rook) { this.PgnMove = this.PgnMove + "=R"; } else if (this.PawnPromotedTo == ChessPieceType.Bishop) { this.PgnMove = this.PgnMove + "=B"; } else if (this.PawnPromotedTo == ChessPieceType.Knight) { this.PgnMove = this.PgnMove + "=N"; } } return(this.PgnMove); }
internal string GeneratePGNString(Board board) { if (!string.IsNullOrEmpty(this.PgnMove)) { return(this.PgnMove); } bool flag1 = false; bool flag2 = false; bool flag3 = false; byte num1 = (byte)((uint)this.MovingPiecePrimary.SrcPosition % 8U); byte num2 = (byte)(8 - (int)this.MovingPiecePrimary.SrcPosition / 8); byte num3 = (byte)((uint)this.MovingPiecePrimary.DstPosition % 8U); byte num4 = (byte)(8 - (int)this.MovingPiecePrimary.DstPosition / 8); this.PgnMove = ""; for (byte index = 0; (int)index < 64; ++index) { if ((int)index != (int)this.MovingPiecePrimary.DstPosition) { Square square = board.Squares[(int)index]; if (square.Piece != null && square.Piece.PieceType == this.MovingPiecePrimary.PieceType && square.Piece.PieceColor == this.MovingPiecePrimary.PieceColor) { foreach (int validMove in square.Piece.ValidMoves) { if (validMove == (int)this.MovingPiecePrimary.DstPosition) { flag3 = true; int num5 = (int)(byte)((uint)index % 8U); byte num6 = (byte)(8 - (int)index / 8); int num7 = (int)num1; if (num5 == num7) { flag1 = true; } if ((int)num6 == (int)num2) { flag2 = true; break; } break; } } } } } if (this.MovingPieceSecondary.PieceType == ChessPieceType.Rook) { if (this.MovingPieceSecondary.PieceColor == ChessPieceColor.Black) { if ((int)this.MovingPieceSecondary.SrcPosition == 7) { this.PgnMove = this.PgnMove + "O-O"; } else if ((int)this.MovingPieceSecondary.SrcPosition == 0) { this.PgnMove = this.PgnMove + "O-O-O"; } } else if (this.MovingPieceSecondary.PieceColor == ChessPieceColor.White) { if ((int)this.MovingPieceSecondary.SrcPosition == 63) { this.PgnMove = this.PgnMove + "O-O"; } else if ((int)this.MovingPieceSecondary.SrcPosition == 56) { this.PgnMove = this.PgnMove + "O-O-O"; } } } else { this.PgnMove = this.PgnMove + MoveContent.GetPgnMove(this.MovingPiecePrimary.PieceType); switch (this.MovingPiecePrimary.PieceType) { case ChessPieceType.Queen: if (flag3) { if (!flag1) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } if (flag2) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); } this.PgnMove = this.PgnMove + (object)num2; break; } break; case ChessPieceType.Rook: if (flag3) { if (!flag1) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } if (flag2) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); } this.PgnMove = this.PgnMove + (object)num2; break; } break; case ChessPieceType.Bishop: if (flag3) { if (!flag1) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } if (flag2) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); } this.PgnMove = this.PgnMove + (object)num2; break; } break; case ChessPieceType.Knight: if (flag3) { if (!flag1) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } if (flag2) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); } this.PgnMove = this.PgnMove + (object)num2; break; } break; case ChessPieceType.Pawn: if (flag3 && (int)num1 != (int)num3) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } if (this.TakenPiece.PieceType != ChessPieceType.None) { this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num1); break; } break; } if (this.TakenPiece.PieceType != ChessPieceType.None) { this.PgnMove = this.PgnMove + "x"; } this.PgnMove = this.PgnMove + MoveContent.GetColumnFromInt((int)num3); this.PgnMove = this.PgnMove + (object)num4; if (this.PawnPromotedTo == ChessPieceType.Queen) { this.PgnMove = this.PgnMove + "=Q"; } else if (this.PawnPromotedTo == ChessPieceType.Rook) { this.PgnMove = this.PgnMove + "=R"; } else if (this.PawnPromotedTo == ChessPieceType.Bishop) { this.PgnMove = this.PgnMove + "=B"; } else if (this.PawnPromotedTo == ChessPieceType.Knight) { this.PgnMove = this.PgnMove + "=N"; } } return(this.PgnMove); }