order children

This commit is contained in:
Sander Land committed 2020-05-02 15:42:39 +02:00
1 parent 486c1aa2bc
commit 778b6db1cc
3 files changed
+13 -3

No files matched your search

+4
View File
@@ -44,6 +44,10 @@ class GameNode(SGFNode):
]
return properties
@staticmethod
def order_children(children):
return sorted(children, key=lambda c: 0.5 if c.auto_undo is None else int(c.auto_undo)) # analyzed/not undone main, non-teach second, undone last
# various analysis functions
def analyze(self, engine, priority=0, visits=None, time_limit=True, refine_move=None, analyze_fast=False):
engine.request_analysis(
+7 -2
View File
@@ -69,9 +69,14 @@ class SGFNode:
self.set_property(move.player, move.sgf(self.board_size))
def sgf_properties(self, **xargs) -> Dict:
"""For hooking into in a subclass and overriding/formatting any additional properties to be output"""
"""For hooking into in a subclass and overriding/formatting any additional properties to be output."""
return copy.deepcopy(self.properties)
@staticmethod
def order_children(children):
"""For hooking into in a subclass and overriding branch order."""
return children
def sgf(self, **xargs) -> str:
"""Generates an SGF, calling sgf_properties on each node with the given xargs, so it can filter relevant properties if needed."""
import sys
@@ -80,7 +85,7 @@ class SGFNode:
sys.setrecursionlimit(max(sys.getrecursionlimit(), 3 * bszx * bszy)) # thanks to lightvector for causing stack overflows ;)
sgf_str = "".join([prop + "".join(f"[{v}]" for v in values) for prop, values in self.sgf_properties(**xargs).items() if values])
if self.children:
children = [c.sgf(**xargs) for c in self.children]
children = [c.sgf(**xargs) for c in self.order_children(self.children)]
if len(children) == 1:
sgf_str += ";" + children[0]
else:
+2 -1
View File
@@ -1,7 +1,8 @@
from kivy.config import Config # isort:skip
Config.set("input", "mouse", "mouse,multitouch_on_demand") # isort:skip # no red dots on right click
ICON = "img/icon.png"
Config.set("kivy", "window_icon",ICON) # isort:skip # set icon before Window is imported
Config.set("kivy", "window_icon", ICON) # isort:skip # set icon before Window is imported
import signal
import os