Merge branch '1.7' of github.com:sanderland/katrain into 1.7

This commit is contained in:
Sander Land committed 2020-12-18 16:40:06 +01:00
commit 091f5a26ce
8 files changed
+186 -188

No files matched your search

+11 -2
View File
@@ -64,10 +64,15 @@ class Move:
"""Returns True if the move is a pass"""
return self.coords is None
@staticmethod
def opponent_player(player):
"""Returns the opposing player, i.e. W <-> B"""
return "W" if player == "B" else "B"
@property
def opponent(self):
"""Returns the opposing player, i.e. W <-> B"""
return "W" if self.player == "B" else "B"
return self.opponent_player(self.player)
class SGFNode:
@@ -288,7 +293,11 @@ class SGFNode:
@property
def next_player(self):
"""Returns player to move"""
if "B" in self.properties or ("AB" in self.properties and "W" not in self.properties): # root or black moved
if "PL" in self.properties: # explicit
return "B" if self.get_property("PL").upper().strip() == "B" else "W"
elif "B" in self.properties or (
"AB" in self.properties and "W" not in self.properties and "AW" not in self.properties
): # b move or setup with only black moves like root handicap
return "W"
else:
return "B"