Skip to content

Commit

Permalink
Added support to write back to PGN with comments and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-bovet committed May 10, 2021
1 parent 3a88310 commit c8e8493
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 83 deletions.
42 changes: 21 additions & 21 deletions BChessTests/PGNTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void assertOutputPGN(const char *pgnGame, std::string expectedFEN, std::s
std::string actualFEN = FFEN::getFEN(game.board);
EXPECT_STREQ(expectedFEN.c_str(), actualFEN.c_str());

auto generatedPGN = FPGN::getGame(game);
auto generatedPGN = FPGN::getGame(game, FPGN::Formatting::history);
EXPECT_STREQ(outputPGN.c_str(), generatedPGN.c_str());

// Now let's try again the assert the game using the generated PGN and the expected FEN of the game
Expand Down Expand Up @@ -127,7 +127,7 @@ TEST_F(PGN, ParseMove) {

auto fpgn = FPGN("e4 e5");
ASSERT_TRUE(fpgn.parseMove(move));
fpgn.getGame().move(move, false);
fpgn.getGame().move(move, "", false);
ASSERT_TRUE(fpgn.parseMove(move));
ASSERT_EQ(squareForName("e7"), MOVE_FROM(move));
ASSERT_EQ(squareForName("e5"), MOVE_TO(move));
Expand Down Expand Up @@ -175,13 +175,13 @@ TEST_F(PGN, GameInput) {
}

TEST_F(PGN, GameOutput) {
assertOutputPGN(move1to3, "r1bqkbnr/1ppp1ppp/p1n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 0 4", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 *");
assertOutputPGN(move1to3, "r1bqkbnr/1ppp1ppp/p1n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 0 4", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {This opening is called the Ruy Lopez.} *");

assertOutputPGN(move1to10, "r1bq1rk1/2pnbppp/p2p1n2/1p2p3/3PP3/1BP2N1P/PP3PP1/RNBQR1K1 w - - 1 11", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 *");
assertOutputPGN(move1to10, "r1bq1rk1/2pnbppp/p2p1n2/1p2p3/3PP3/1BP2N1P/PP3PP1/RNBQR1K1 w - - 1 11", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {This opening is called the Ruy Lopez.} 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 *");

assertOutputPGN(move1to34, "8/6p1/3k4/R2n1bp1/1p6/1P3P1P/5KP1/8 w - - 3 35", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5 Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6 23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5 hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5 *");
assertOutputPGN(move1to34, "8/6p1/3k4/R2n1bp1/1p6/1P3P1P/5KP1/8 w - - 3 35", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {This opening is called the Ruy Lopez.} 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5 Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6 23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5 hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5 *");

assertOutputPGN(allMoves, "8/8/4R1p1/2k3p1/1p4P1/1P1b1P2/3K1n2/8 b - - 2 43", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5 Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6 23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5 hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5 35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3 Nxh3 39. Kd2 Kb5 40. Rd6 Kc5 41. Ra6 Nf2 42. g4 Bd3 43. Re6 1/2-1/2");
assertOutputPGN(allMoves, "8/8/4R1p1/2k3p1/1p4P1/1P1b1P2/3K1n2/8 b - - 2 43", "1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {This opening is called the Ruy Lopez.} 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5 Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6 23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5 hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5 35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3 Nxh3 39. Kd2 Kb5 40. Rd6 Kc5 41. Ra6 Nf2 42. g4 Bd3 43. Re6 1/2-1/2");
}

TEST_F(PGN, GameWithBlackFromFEN) {
Expand All @@ -190,29 +190,29 @@ TEST_F(PGN, GameWithBlackFromFEN) {
game.move("c1", "d1");

auto pgn = FPGN::getGame(game);
ASSERT_EQ(pgn, "[FEN \"1K1k4/1P6/8/8/8/8/r7/2R5 w - - 0 1\"]\n[Setup \"1\"]\n1. Rd1+ *");
ASSERT_EQ("[Event \"\"]\n[Site \"\"]\n[Date \"\"]\n[Round \"\"]\n[White \"\"]\n[Black \"\"]\n[Result \"\"]\n[FEN \"1K1k4/1P6/8/8/8/8/r7/2R5 w - - 0 1\"]\n[Setup \"1\"]\n\n 1. Rd1+ *", pgn);
}

TEST_F(PGN, GameWithBlackPromotion) {
ChessGame game;
ASSERT_TRUE(FPGN::setGame("1.e4 Nf6 2.Nc3 Nxe4 3.Nxe4 d5 4.Nc3 Qd6 5.Nf3 h5 6.d4 Qd8 7.Bb5+ c6 8.Ba4 b5 9.Bb3 a5 10.a4 b4 11.Na2 Bg4 12.Qd3 Bxf3 13.Qxf3 h4 14.h3 Qd6 15.Bf4 Qe6+ 16.Be3 Qd6 17.O-O g6 18.c4 bxc3 19.bxc3 Nd7 20.c4 dxc4 21.Bxc4 Qf6 22.Qg4 e5 23.Rfe1 Qg7 24.dxe5 Nc5 25.Bxc5 Bxc5 26.e6 Bd4 27.exf7+ Kf8 28.Qe6 Qf6 29.Rad1 Qxe6 30.Bxe6 c5 31.Bd5 Rb8 32.Nc1 Rh5 33.Bc4 Rf5 34.Re2 Rf4 35.Rde1 Bxf2+ 36.Rxf2 Rxc4 37.Nd3 Kg7 38.Re7 Kf8 39.Re6 Rxa4 40.Nxc5 Ra1+ 41.Kh2 Rd1 42.Ne4 Kg7 43.Ng5 Rf8 44.Rfe2 Rxf7 45.Nxf7 Kxf7 46.R6e4 Ra1 47.Rxh4 Kg8 48.Rf2 Kg7 49.Rhf4 a4 50.Rf7+ Kh6 51.R2f4 a3 52.Rg4 a2 53.Rf6 Rh1+ 54.Kxh1 *", game));

auto move = createPromotion(squareForName("a2"), squareForName("a1"), BLACK, PAWN, QUEEN);
game.move(move, false);
game.move(move, "", false);

auto pgn = FPGN::getGame(game);
auto pgn = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ(pgn, "1. e4 Nf6 2. Nc3 Nxe4 3. Nxe4 d5 4. Nc3 Qd6 5. Nf3 h5 6. d4 Qd8 7. Bb5+ c6 8. Ba4 b5 9. Bb3 a5 10. a4 b4 11. Na2 Bg4 12. Qd3 Bxf3 13. Qxf3 h4 14. h3 Qd6 15. Bf4 Qe6+ 16. Be3 Qd6 17. O-O g6 18. c4 bxc3 19. bxc3 Nd7 20. c4 dxc4 21. Bxc4 Qf6 22. Qg4 e5 23. Rfe1 Qg7 24. dxe5 Nc5 25. Bxc5 Bxc5 26. e6 Bd4 27. exf7+ Kf8 28. Qe6 Qf6 29. Rad1 Qxe6 30. Bxe6 c5 31. Bd5 Rb8 32. Nc1 Rh5 33. Bc4 Rf5 34. Re2 Rf4 35. Rde1 Bxf2+ 36. Rxf2 Rxc4 37. Nd3 Kg7 38. Re7 Kf8 39. Re6 Rxa4 40. Nxc5 Ra1+ 41. Kh2 Rd1 42. Ne4 Kg7 43. Ng5 Rf8 44. Rfe2 Rxf7 45. Nxf7 Kxf7 46. Re6e4 Ra1 47. Rxh4 Kg8 48. Rf2 Kg7 49. Rhf4 a4 50. Rf7+ Kh6 51. Rf2f4 a3 52. Rg4 a2 53. Rf6 Rh1+ 54. Kxh1 a1=Q+ *");
}

TEST_F(PGN, OutputFromInitialPosition) {
ChessGame game;
ASSERT_EQ(StartFEN, game.initialFEN);

ASSERT_EQ("*", FPGN::getGame(game));
ASSERT_EQ("*", FPGN::getGame(game, FPGN::Formatting::history));

game.move("e2", "e4");

ASSERT_EQ("1. e4 *", FPGN::getGame(game));
ASSERT_EQ("1. e4 *", FPGN::getGame(game, FPGN::Formatting::history));
}

TEST_F(PGN, InputFromInitialPosition) {
Expand All @@ -222,7 +222,7 @@ TEST_F(PGN, InputFromInitialPosition) {

FPGN::setGame("1. e4 *", game);

ASSERT_EQ("1. e4 *", FPGN::getGame(game));
ASSERT_EQ("1. e4 *", FPGN::getGame(game, FPGN::Formatting::history));
}

TEST_F(PGN, OutputFromPosition) {
Expand All @@ -233,7 +233,7 @@ TEST_F(PGN, OutputFromPosition) {
ASSERT_EQ(fen.c_str(), game.initialFEN);

auto pgn = FPGN::getGame(game);
ASSERT_EQ("[FEN \"r1bqkbnr/ppp1pppp/2n5/3p4/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3\"]\n[Setup \"1\"]\n*", pgn);
ASSERT_EQ("[Event \"\"]\n[Site \"\"]\n[Date \"\"]\n[Round \"\"]\n[White \"\"]\n[Black \"\"]\n[Result \"\"]\n[FEN \"r1bqkbnr/ppp1pppp/2n5/3p4/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3\"]\n[Setup \"1\"]\n\n *", pgn);
}

TEST_F(PGN, InputFromPosition) {
Expand All @@ -260,7 +260,7 @@ TEST_F(PGN, PGNWithSimpleWhiteVariation) {
ASSERT_EQ(1, game.getNumberOfMoves());
ASSERT_EQ(2, game.getRoot().variations.size());

auto pgnAgain = FPGN::getGame(game);
auto pgnAgain = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ("1. e4 (1. d4) *", pgnAgain);
}

Expand All @@ -274,7 +274,7 @@ TEST_F(PGN, PGNWithSimpleBlackVariation) {
ASSERT_EQ(1, game.getRoot().variations.size());
ASSERT_EQ(2, game.getRoot().variations[0].variations.size());

auto pgnAgain = FPGN::getGame(game);
auto pgnAgain = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ("1. e4 e5 (1... c5) *", pgnAgain);
}

Expand All @@ -286,7 +286,7 @@ TEST_F(PGN, PGNWithVariation1) {

ASSERT_EQ(12, game.getNumberOfMoves());

auto pgnAgain = FPGN::getGame(game);
auto pgnAgain = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ("1. e4 e5 2. Nc3 Nf6 3. f4 d5 4. fxe5 Nxe4 5. Qf3 Nxc3 (5... Nc6) 6. bxc3 Be7 *", pgnAgain);
}

Expand All @@ -298,16 +298,16 @@ TEST_F(PGN, PGNWithVariation2) {

ASSERT_EQ(3, game.getNumberOfMoves());

auto pgnAgain = FPGN::getGame(game);
ASSERT_EQ("1. e4 e5 2. Nc3 (2. Nf3 Nc6 3. Nc3 Nf6) *", pgnAgain);
auto pgnAgain = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ("1. e4 e5 { Normal opening } 2. Nc3 (2. Nf3 Nc6 3. Nc3 Nf6) *", pgnAgain);
}

TEST_F(PGN, LineFromCursor) {
ChessGame game;
ASSERT_TRUE(FPGN::setGame(move1to3, game));

auto line = FPGN::getGame(game, FPGN::Formatting::line, 2);
ASSERT_EQ("Nf3 Nc6 Bb5 a6", line);
ASSERT_EQ("Nf3 Nc6 Bb5 a6 {This opening is called the Ruy Lopez.}", line);
}

TEST_F(PGN, MoveWithNumberInFront) {
Expand All @@ -318,7 +318,7 @@ TEST_F(PGN, MoveWithNumberInFront) {

ASSERT_EQ(4, game.getNumberOfMoves());

auto pgnAgain = FPGN::getGame(game);
auto pgnAgain = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ("1. e4 e5 2. Nf3 Nc6 *", pgnAgain);
}

Expand All @@ -330,6 +330,6 @@ TEST_F(PGN, Game1) {

ASSERT_EQ(52, game.getNumberOfMoves());

auto pgnAgain = FPGN::getGame(game);
auto pgnAgain = FPGN::getGame(game, FPGN::Formatting::history);
ASSERT_EQ("1. e4 e5 2. Nf3 Nc6 3. Nc3 Nf6 4. Bc4 Nxe4 5. Nxe4 d5 6. Bxd5 Qxd5 7. Nc3 Qd6 8. O-O Bg4 9. h3 Bh5 10. Nb5 Qe7 11. c3 O-O-O 12. Qc2 Qf6 13. Nh2 Be2 14. Nxa7+ Nxa7 15. Re1 Bd3 16. Qa4 Bc5 17. Ng4 Qh4 18. b4 Bb6 19. Rxe5 h5 20. Ne3 Rh6 21. Bb2 Rf6 22. f3 Rxf3 23. Re8 Qf2+ 24. Kh1 Rg3 25. Rd1 Qxg2+ 26. Nxg2 Rxh3# 0-1", pgnAgain);
}
12 changes: 6 additions & 6 deletions Shared/Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ struct Actions {
func analyzeReset() {
document.selection = Selection.empty()
document.lastMove = nil
document.pgn = document.pgnBeforeAnalyzing
document.pgn = document.mode.pgnBeforeAnalyzing
document.engine.setPGN(document.pgn)
}

func changeBoardState(state: ChessDocument.State) {
if document.state == .play {
document.state = state
document.pgnBeforeAnalyzing = document.pgn
func changeBoardState(state: GameMode.Value) {
if document.mode.value == .play {
document.mode.value = state
document.mode.pgnBeforeAnalyzing = document.pgn
if state == .train {
engine.setFEN(StartPosFEN)
}
} else {
document.state = .play
document.mode.value = .play
analyzeReset()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Shared/Bridge/FEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ - (FEngineMove*)engineMoveFromMove:(Move)fmove {
}

- (void)move:(NSUInteger)move {
engine.move((Move)move, true);
engine.move((Move)move, "", true);
[self fireUpdate:self.stateIndex];
}

Expand Down
2 changes: 1 addition & 1 deletion Shared/Bridge/FEngineInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (NSString*)bestLine:(BOOL)uci {
lineGame.history = NEW_HISTORY; // TODO hack to avoid coping the history from self.game and got it overwritten here
for (int index=0; index<self.info.line.count; index++) {
Move move = self.info.line[index];
lineGame.move(move, false);
lineGame.move(move, "", false);
}

// Get the PGN representation of the best line only
Expand Down
38 changes: 21 additions & 17 deletions Shared/ChessDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ struct GamePlayer: Codable {
var level: Int
}

// The mode of game
struct GameMode {
enum Value {
case play
case analyze
case train
}

// Contains the PGN before the analyze started, so we can restore it
var pgnBeforeAnalyzing = ""

// The state of the board (see enum above)
var value: Value = .play
}

struct ChessDocument: FileDocument {

static let startPosPGN = "*"
Expand All @@ -49,17 +64,8 @@ struct ChessDocument: FileDocument {
var lastMove: FEngineMove? = nil
var info: FEngineInfo? = nil

enum State {
case play
case analyze
case train
}
var mode: GameMode

// Contains the PGN before the analyze started, so we can restore it
var pgnBeforeAnalyzing = ""
// The state of the board (see enum above)
var state: State = .play

// This variable is used by any action that needs the engine to move
// if suitable. For example, after New Game or Edit Game.
// If is observed in the PiecesView view.
Expand All @@ -69,13 +75,13 @@ struct ChessDocument: FileDocument {
return PiecesFactory().pieces(forState: engine.state)
}

init(pgn: String = startPosPGN, white: GamePlayer? = nil, black: GamePlayer? = nil, rotated: Bool = false, state: State = .play) {
init(pgn: String = startPosPGN, white: GamePlayer? = nil, black: GamePlayer? = nil, rotated: Bool = false, mode: GameMode = GameMode(value: .play)) {
self.pgn = pgn
self.engine.setPGN(pgn)
self.whitePlayer = white ?? GamePlayer(name: "", computer: false, level: 0)
self.blackPlayer = black ?? GamePlayer(name: "", computer: true, level: 0)
self.rotated = rotated
self.state = state
self.mode = mode
loadOpenings()
}

Expand Down Expand Up @@ -112,17 +118,15 @@ struct ChessDocument: FileDocument {
}

func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
// If analyzing, don't save the pgn but rather the savedPGN which is the PGN before the analyze started
let actualPGN = state != .play ? pgnBeforeAnalyzing : pgn

let pgnToWrite = mode.value != .play ? mode.pgnBeforeAnalyzing : pgn
switch configuration.contentType {
case .exampleText:
let state = GameState(pgn: actualPGN, rotated: rotated, white: whitePlayer, black: blackPlayer)
let state = GameState(pgn: pgnToWrite, rotated: rotated, white: whitePlayer, black: blackPlayer)
let encoder = JSONEncoder()
let data = try encoder.encode(state)
return .init(regularFileWithContents: data)
case .pgn:
if let data = actualPGN.data(using: .utf8) {
if let data = pgnToWrite.data(using: .utf8) {
return .init(regularFileWithContents: data)
} else {
throw CocoaError(.fileWriteInapplicableStringEncoding)
Expand Down
4 changes: 2 additions & 2 deletions Shared/Engine/Engine/ChessEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class ChessEngine {
return game.movesAt(file, rank);
}

void move(Move move, bool replace) {
game.move(move, replace);
void move(Move move, std::string comment, bool replace) {
game.move(move, comment, replace);
}

void move(std::string from, std::string to) {
Expand Down
7 changes: 4 additions & 3 deletions Shared/Engine/Engine/ChessGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ std::vector<Move> ChessGame::allMoves() {
// move: the move to perform
// replace: true to replace any variations by this move only,
// false to add as a new variation if the move does not exist already
void ChessGame::move(Move move, bool replace) {
void ChessGame::move(Move move, std::string comment, bool replace) {
assert(MOVE_ISVALID(move));

// Lookup the node representing the last move by `moveIndexes`
root.lookupNode(0, moveIndexes.moveCursor, moveIndexes, [&move, replace, this](auto & node) {
root.lookupNode(0, moveIndexes.moveCursor, moveIndexes, [&move, &comment, replace, this](auto & node) {
bool found = false;
if (replace) {
// Clear all the variations so this move
Expand All @@ -90,6 +90,7 @@ void ChessGame::move(Move move, bool replace) {
// this is a new variation (either main variation if no variation exists yet).
if (!found || replace) {
MoveNode newNode = MoveNode();
newNode.comment = comment;
newNode.move = move;
node.variations.push_back(newNode);

Expand Down Expand Up @@ -122,7 +123,7 @@ void ChessGame::move(Move move, bool replace) {
void ChessGame::move(std::string from, std::string to) {
auto move = board.getMove(from, to);
if (MOVE_ISVALID(move)) {
ChessGame::move(move, false);
ChessGame::move(move, "", false);
}
}

Expand Down
4 changes: 3 additions & 1 deletion Shared/Engine/Engine/ChessGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ChessGame {
struct MoveNode {
// Representation of this node's move
Move move;

std::string comment;

// List representing the next node following this one.
// In other words, this list contains the moves that can be
Expand Down Expand Up @@ -161,7 +163,7 @@ class ChessGame {
std::vector<Move> movesAt(File file, Rank rank);
std::vector<Move> allMoves();

void move(Move move, bool replace);
void move(Move move, std::string comment, bool replace);
void move(std::string from, std::string to);

bool canUndoMove();
Expand Down
Loading

0 comments on commit c8e8493

Please sign in to comment.