2 files changed
+3
-2
No files matched your search
+1
-1
@@ -91,7 +91,7 @@ def ai_rank_estimation(strategy, settings) -> int:
|
||||
|
||||
def weighted_selection_without_replacement(items: List[Tuple], pick_n: int) -> List[Tuple]:
|
||||
"""For a list of tuples where the second element is a weight, returns random items with those weights, without replacement."""
|
||||
elt = [(math.log(random.random()) / item[1], item) for item in items] # magic
|
||||
elt = [(math.log(random.random()) / (item[1] + 1e-18), item) for item in items] # magic
|
||||
return [e[1] for e in heapq.nlargest(pick_n, elt)] # NB fine if too small
|
||||
|
||||
|
||||
|
||||
@@ -90,10 +90,11 @@ class ControlsPanel(BoxLayout):
|
||||
def set_status(self, msg, status_type, at_node=None):
|
||||
at_node = at_node or self.katrain and self.katrain.game and self.katrain.game.current_node
|
||||
if at_node != self.status_state[2] or int(status_type) >= int(self.status_state[1]) or msg == "":
|
||||
if self.status_state != (msg, status_type, at_node): # prevent loop if error in update eval
|
||||
Clock.schedule_once(self.update_evaluation, 0)
|
||||
self.status_state = (msg, status_type, at_node)
|
||||
self.status.text = msg
|
||||
self.status.error = status_type == STATUS_ERROR
|
||||
Clock.schedule_once(self.update_evaluation, 0)
|
||||
|
||||
# handles showing completed analysis and score graph
|
||||
def update_evaluation(self, *_args):
|
||||
|
||||
Reference in new issue
Block a user