def setOpening(self, ply=None, redetermine=False): if ply is None: ply = self.ply opening = None while ply >= self.lowply: opening = get_eco(self.getBoardAtPly(ply).board.hash, exactPosition=True) if opening is None and redetermine: ply = ply - 1 else: break if opening is not None: self.tags["ECO"] = opening[0] self.tags["Opening"] = opening[1] self.tags["Variation"] = opening[2] else: if redetermine: if 'ECO' in self.tags: del self.tags['ECO'] if 'Opening' in self.tags: del self.tags['Opening'] if 'Variation' in self.tags: del self.tags['Variation'] self.emit("opening_changed")
def setOpening(self): if self.ply > 40: return if self.ply > 0: opening = get_eco(self.getBoardAtPly(self.ply).board.hash) else: opening = ("", "", "") if opening is not None: self.tags["ECO"] = opening[0] self.tags["Opening"] = opening[1] self.tags["Variation"] = opening[2]
def setOpening(self): if self.ply > 40: return if self.ply > 0: opening = get_eco(self.getBoardAtPly(self.ply).board.hash) else: opening = ("", "", "") if opening is not None: self.tags["ECO"] = opening[0] self.tags["Opening"] = opening[1] self.tags["Variation"] = opening[2] self.emit("opening_changed")
def shownChanged(self, boardview, shown): m = boardview.model if m is None or m.isPlayingICSGame(): return b = m.getBoardAtPly(shown, boardview.shown_variation_idx) parent = self.empty_parent() openings = getOpenings(b.board) openings.sort(key=lambda t: t[1], reverse=True) if not openings: return totalWeight = 0.0 # Polyglot-formatted books have space for learning data. # See version ac31dc37ec89 for an attempt to parse it. # In this version, we simply ignore it. (Most books don't have it.) for move, weight, learn in openings: totalWeight += weight self.opening_names = [] for move, weight, learn in openings: if totalWeight != 0: weight /= totalWeight goodness = min(float(weight * len(openings)), 1.0) weight = "%0.1f%%" % (100 * weight) opening = get_eco(b.move(Move(move)).board.hash) if opening is None: eco = "" # self.opening_names.append("") else: eco = "%s - %s %s" % (opening[0], opening[1], opening[2]) # self.opening_names.append("%s %s" % (opening[1], opening[2])) self.store.append( parent, [ (b, Move(move), None), (weight, 1, goodness), 0, False, eco, False, False, ], ) tp = Gtk.TreePath(self.path) self.tv.expand_row(tp, False)
def setOpening(self, ply=None): if ply is None: ply = self.ply if ply > 40: return if ply > 0: opening = get_eco(self.getBoardAtPly(ply).board.hash) else: opening = ("", "", "") if opening is not None: self.tags["ECO"] = opening[0] self.tags["Opening"] = opening[1] self.tags["Variation"] = opening[2] self.emit("opening_changed")
def shownChanged(self, boardview, shown): m = boardview.model if m is None: return if m.isPlayingICSGame(): return b = m.getBoardAtPly(shown, boardview.shown_variation_idx) parent = self.empty_parent() openings = getOpenings(b.board) openings.sort(key=lambda t: t[1], reverse=True) if not openings: return totalWeight = 0.0 # Polyglot-formatted books have space for learning data. # See version ac31dc37ec89 for an attempt to parse it. # In this version, we simply ignore it. (Most books don't have it.) for move, weight, games, score in openings: totalWeight += weight self.opening_names = [] for move, weight, games, score in openings: if totalWeight != 0: weight /= totalWeight goodness = min(float(weight * len(openings)), 1.0) weight = "%0.1f%%" % (100 * weight) opening = get_eco(b.move(Move(move)).board.hash) if opening is None: eco = "" # self.opening_names.append("") else: eco = "%s - %s %s" % (opening[0], opening[1], opening[2]) # self.opening_names.append("%s %s" % (opening[1], opening[2])) self.store.append(parent, [(b, Move(move), None), ( weight, 1, goodness), 0, False, eco, False, False]) tp = Gtk.TreePath(self.path) self.tv.expand_row(tp, False)