private void addPGNMove(List <Movement> move, string comment) { PGNGame.MoveData md = new PGNGame.MoveData(); md.Key = Game.Board.HashCode; md.Move = move[0]; md.MoveString = Game.DescribeMove(move[0], MoveNotation.StandardAlgebraic /* TODO: change to SAN */); md.Comment = comment; PGN.AddMove(md); }
public string ToString(byte[] d) { string msg = PGN.ToString(); foreach (KeesField f in Fields) { msg = msg + '\n' + f.Name + '\n' + f.ToString(d); } return(msg); }
private void initializePgn() { PGN.Variant = Game.GameAttribute.GameName; string currentPlayer = Game.FEN["current player"]; PGN.SetStartingFenString(currentPlayer == "w" ? 0 : 1, m_startingFen); PGN.Date = DateTime.Now.ToString("yyyy.MM.dd"); PGN.SetPlayerName(0, m_player[0].Name); PGN.SetPlayerName(1, m_player[1].Name); PGN.Result = Result; if (m_timeControl[0] == m_timeControl[1]) { PGN.SetTag("TimeControl", m_timeControl[0].ToString()); } else { PGN.SetTag("WhiteTimeControl", m_timeControl[0].ToString()); PGN.SetTag("BlackTimeControl", m_timeControl[1].ToString()); } }
public void Stop() { if (IsFinished) { return; } // Don't actually cancel the game if both players are either // HumanPlayer or InternalEngine so that we can still take back // moves and keep playing. if ((m_player[0] is HumanPlayer || m_player[0] is InternalEngine) && (m_player[1] is HumanPlayer || m_player[1] is InternalEngine)) { return; } IsFinished = true; // raise HumanEnabled event HumanEnabled(false); if (!m_gameInProgress) { Result = new Result(); finish(); return; } m_gameInProgress = false; PGN.SetTag("PlyCount", PGN.Moves.Count.ToString()); PGN.Result = Result; PGN.SetResultDescription(Result.Description); m_player[0].EndGame(Result); m_player[1].EndGame(Result); PlayersReady += finish; // connect(this, SIGNAL(playersReady()), this, SLOT(finish()), Qt::QueuedConnection); syncPlayers(); }
// ReSharper disable once InconsistentNaming private static string GeneratePNG(Engine engine, PGN.Result result) { var white = ""; var black = ""; switch (GameStatData.GameSetup) { case GameSetup.PlayerWhiteVsPlayerBlack: white = "Игрок"; black = "Игрок"; break; case GameSetup.PlayerWhiteVsAiBlack: white = "Игрок"; black = "Компьютер"; break; case GameSetup.PlayerBlackVsAiWhite: white = "Компьютер"; black = "Игрок"; break; case GameSetup.AiWhiteVsAiBlack: white = "Компьютер"; black = "Компьютер"; break; case GameSetup.None: break; default: throw new ArgumentOutOfRangeException(); } return(PGN.GeneratePGN(engine.GetMoveHistory(), white, black, result)); }
public MoveResult MakeMove(string move) { GenerateAllAlgebraicAvailableMoves(); MoveResult result = MoveResult.Invalid; for (int i = 0; i < AlgebraicAvailableMoves.Count; i++) { if (AlgebraicAvailableMoves[i] == move) { result = MoveResult.Valid; if (move != "e1g1" && move != "e1c1" && move != "e8g8" && move != "e8c8") { //then we are dealing with a non-castling move PGN.Add(move); string firstSquare = move.Substring(0, 2); string secondSquare = move.Substring(2, 2); Piece pieceThatMoves = Pieces[MapTo120[AlgebraicToIntegerIndex[firstSquare]]]; int pieceThatMovesBit = BitBoard[MapTo120[AlgebraicToIntegerIndex[firstSquare]]]; Pieces[MapTo120[AlgebraicToIntegerIndex[firstSquare]]] = null; BitBoard[MapTo120[AlgebraicToIntegerIndex[firstSquare]]] = 0; Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]] = pieceThatMoves; Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]].Position = MapTo120[AlgebraicToIntegerIndex[secondSquare]]; BitBoard[MapTo120[AlgebraicToIntegerIndex[secondSquare]]] = pieceThatMovesBit; if (Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]].GetType() == typeof(King)) { //update king position if (Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]].Color == "white") { PositionOfWhiteKing = MapTo120[AlgebraicToIntegerIndex[secondSquare]]; } else if (Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]].Color == "black") { PositionOfBlackKing = MapTo120[AlgebraicToIntegerIndex[secondSquare]]; } } Turn = Turn * -1; DetermineIfCheck(); DetermineIfCheckMate(); if (checkStatus != 0) { result = MoveResult.Check; } if (checkMateStatus != 0) { result = MoveResult.Checkmate; } } else { //dealing with castling move PGN.Add(move); //first handle the king string firstSquare = move.Substring(0, 2); string secondSquare = move.Substring(2, 2); Piece pieceThatMoves = Pieces[MapTo120[AlgebraicToIntegerIndex[firstSquare]]]; int pieceThatMovesBit = BitBoard[MapTo120[AlgebraicToIntegerIndex[firstSquare]]]; Pieces[MapTo120[AlgebraicToIntegerIndex[firstSquare]]] = null; BitBoard[MapTo120[AlgebraicToIntegerIndex[firstSquare]]] = 0; Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]] = pieceThatMoves; Pieces[MapTo120[AlgebraicToIntegerIndex[secondSquare]]].Position = MapTo120[AlgebraicToIntegerIndex[secondSquare]]; BitBoard[MapTo120[AlgebraicToIntegerIndex[secondSquare]]] = pieceThatMovesBit; //then handle the respective rook Turn = Turn * -1; } } } return(result); }