fix blunder eval?

This commit is contained in:
hagi 2022-12-30 15:46:08 +01:00
parent 793e8ec5ed
commit e93ee7fb7b

View file

@ -46,9 +46,11 @@ class BlunderEvaluator:
self.current_wdl = self.api_wdl() self.current_wdl = self.api_wdl()
self.wdls: list = [] self.wdls: list = []
self.current_fen = self.engine.get_fen_position() self.current_fen = self.engine.get_fen_position()
self.white_to_move = True
def reset(self): def reset(self):
self.engine.set_position() self.engine.set_position()
self.white_to_move = True
def move(self, move) -> None: def move(self, move) -> None:
""" """
@ -69,6 +71,10 @@ class BlunderEvaluator:
# path # path
self.play_sound("blunder") self.play_sound("blunder")
print("Blunder!") print("Blunder!")
if self.white_to_move:
self.white_to_move = False
elif not self.white_to_move:
self.white_to_move = True
else: else:
print("Invalid move") print("Invalid move")
self.play_sound("illegal") self.play_sound("illegal")
@ -112,9 +118,7 @@ class BlunderEvaluator:
""" """
if len(self.wdls) > 1: # Don't check for blunders on the first move if len(self.wdls) > 1: # Don't check for blunders on the first move
previous_wdl = self.wdls[len(self.evaluations) - 2] previous_wdl = self.wdls[len(self.evaluations) - 2]
if abs(previous_wdl[0] - self.current_wdl[0]) > 300: if abs(previous_wdl[0] - self.current_wdl[2]) > 300:
return True
elif abs(previous_wdl[2] - self.current_wdl[2]) > 300:
return True return True
else: else:
return False return False