def game_changed(self, model, ply): if len(self.plot) + model.lowply > ply: return for i in range(len(self.plot) + model.lowply, ply): if i in model.scores: points = model.scores[i][1] else: points = leval.evaluateComplete( model.getBoardAtPly(i).board, WHITE) self.plot.addScore(points) if model.status == DRAW: points = 0 elif model.status == WHITEWON: points = sys.maxsize elif model.status == BLACKWON: points = -sys.maxsize else: if ply in model.scores: points = model.scores[ply][1] else: points = leval.evaluateComplete( model.getBoardAtPly(ply).board, WHITE) self.plot.addScore(points) # As shownChanged will normally be emitted just after game_changed - # if we are viewing the latest position - we can do the selection change # now, and thereby avoid redraw being called twice if self.plot.selected == ply - model.lowply - 1: self.plot.select(ply - model.lowply) self.plot.redraw() # Uncomment this to debug eval function return board = model.boards[-1].board opboard = model.boards[-1].clone().board opboard.setColor(1 - opboard.color) material, phase = leval.evalMaterial(board) if board.color == WHITE: print("material", -material) e1 = leval.evalKingTropism(board) e2 = leval.evalKingTropism(opboard) print("evaluation: %d + %d = %d " % (e1, e2, e1 + e2)) p1 = leval.evalPawnStructure(board, phase) p2 = leval.evalPawnStructure(opboard, phase) print("pawns: %d + %d = %d " % (p1, p2, p1 + p2)) print("knights:", -leval.evalKnights(board)) print("king:", -leval.evalKing(board, phase)) else: print("material", material) print("evaluation:", leval.evalKingTropism(board)) print("pawns:", leval.evalPawnStructure(board, phase)) print("pawns2:", leval.evalPawnStructure(opboard, phase)) print("pawns3:", leval.evalPawnStructure(board, phase) + leval.evalPawnStructure(opboard, phase)) print("knights:", leval.evalKnights(board)) print("king:", leval.evalKing(board, phase)) print("----------------------")