From 84cdf65c3aafd186bf12fb5434e2f6496291dbc4 Mon Sep 17 00:00:00 2001 From: Tibor Bizjak Date: Thu, 12 Sep 2019 13:00:04 +0200 Subject: [PATCH] Fixed bug; moves stack cut too long on rebase --- chess.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chess.py b/chess.py index 0fd09a6..ec1b186 100644 --- a/chess.py +++ b/chess.py @@ -199,7 +199,7 @@ class Game: """Shorten moves and history stacks if move is made while past game state is loaded into memory. Essentialy overrides future game states.""" - self.moves = self.moves[:self.index+1] + self.moves = self.moves[:self.index] self.history = self.history[:self.index+1] def timetravel(self, i): @@ -528,4 +528,11 @@ class Game: return True - +game = Game() +while True: + i = input(">> ") + game.AN_move(i) + if i =="prev": + game.prev() + print(game) + print(game.index, len(game.history), len(game.moves))