Fixed bug; moves stack cut too long on rebase

master
Tibor Bizjak 2019-09-12 13:00:04 +02:00
parent 9f6a78c7ea
commit 84cdf65c3a
1 changed files with 9 additions and 2 deletions

View File

@ -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))