Skip to content

Commit

Permalink
Use deepcopy on cached boards
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Dec 23, 2014
1 parent b5b8beb commit 6203406
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chess/pgn.py
Expand Up @@ -81,6 +81,7 @@ def __init__(self):
self.starting_comment = ""
self.comment = ""
self.variations = []

self.board_cached = None

def board(self):
Expand All @@ -89,12 +90,11 @@ def board(self):
It's a copy, so modifying the board will not alter the game.
"""

if not self.board_cached:
self.board_cached = self.parent.board()
self.board_cached.push(self.move)
return copy.copy(self.board_cached)

return copy.deepcopy(self.board_cached)

def san(self):
"""
Expand Down

0 comments on commit 6203406

Please sign in to comment.