Skip to content

Commit

Permalink
Fix a crash when a game to be analyzed has not move
Browse files Browse the repository at this point in the history
  • Loading branch information
fsmosca committed Mar 20, 2021
1 parent 11636ee commit 1e57fb8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions chess_artist.py
Expand Up @@ -9,7 +9,7 @@

__author__ = 'fsmosca'
__script_name__ = 'Chess Artist'
__version__ = 'v2.26.0'
__version__ = 'v2.27.0'
__credits__ = ['alxlk', 'ddugovic', 'huytd', 'kennyfrc', 'python-chess']


Expand Down Expand Up @@ -1686,6 +1686,8 @@ def SaveMaterialBalance(game):
"""
mat = []
gameNode = game
nextNode = None

while gameNode.variations:
board = gameNode.board()
fen = board.fen()
Expand All @@ -1695,9 +1697,10 @@ def SaveMaterialBalance(game):
nextNode = gameNode.variation(0)

gameNode = nextNode

endFen = nextNode.board().fen()
mat.append([endFen, Analyze.GetMaterialBalance(endFen)])

if nextNode is not None:
endFen = nextNode.board().fen()
mat.append([endFen, Analyze.GetMaterialBalance(endFen)])

return mat

Expand Down

0 comments on commit 1e57fb8

Please sign in to comment.