From f44d6d2fd4ec324d832185d20db264fd2e8b1bb9 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Wed, 23 Sep 2020 00:30:11 +0800 Subject: [PATCH] =?UTF-8?q?position:=20=E5=A2=9E=E5=8A=A0=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=20undo=20=E5=87=BD=E6=95=B0=E5=A3=B0=E6=98=8E?= =?UTF-8?q?=E4=BD=86=E6=9A=82=E6=9C=AA=E5=AE=8C=E6=88=90=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/position.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/position.h b/src/position.h index 1eb76c4c..c7541d4b 100644 --- a/src/position.h +++ b/src/position.h @@ -172,12 +172,18 @@ public: // Other helpers bool select_piece(Square s); bool select_piece(File file, Rank rank); - bool put_piece(Square s, bool updateCmdlist = false); + bool put_piece(File file, Rank rank); - bool remove_piece(Square s, bool updateCmdlist = false); + bool put_piece(Square s, bool updateCmdlist = false); + bool undo_put_piece(Square s); + bool remove_piece(File file, Rank rank); - bool move_piece(Square from, Square to); + bool remove_piece(Square s, bool updateCmdlist = false); + bool undo_remove_piece(Square s); + bool move_piece(File f1, Rank r1, File f2, Rank r2); + bool move_piece(Square from, Square to); + bool undo_move_piece(Square from, Square to); // Data members Piece board[SQUARE_NB]; @@ -351,6 +357,11 @@ inline bool Position::move_piece(Square from, Square to) return false; } +inline bool Position::undo_move_piece(Square from, Square to) +{ + return move_piece(to, from); // TODO +} + /// Mill Game inline Piece *Position::get_board() const