cleanup
This commit is contained in:
parent
a2ac1bcb39
commit
f11f25f897
|
@ -3,24 +3,23 @@ from pathlib import Path
|
||||||
from pygame import mixer
|
from pygame import mixer
|
||||||
import random
|
import random
|
||||||
from stockfish import Stockfish
|
from stockfish import Stockfish
|
||||||
import time
|
|
||||||
import movegenerator
|
|
||||||
|
|
||||||
sound_path = Path("../../sounds")
|
sound_path = Path("../../sounds")
|
||||||
|
|
||||||
|
|
||||||
settings = { # TODO Move to a config file
|
class BlunderEvaluator:
|
||||||
|
default_engine_settings = {
|
||||||
"Debug Log File": "stocklog.txt",
|
"Debug Log File": "stocklog.txt",
|
||||||
"Contempt": 0,
|
"Contempt": 0,
|
||||||
"Min Split Depth": 0,
|
"Min Split Depth": 0,
|
||||||
"Threads": 1,
|
"Threads": 1,
|
||||||
# More threads will make the engine stronger, but should be kept at less than the
|
# More threads will make the engine stronger, but should be kept at less than
|
||||||
# number of logical processors on your computer.
|
# the number of logical processors on your computer.
|
||||||
"Ponder": "false",
|
"Ponder": "false",
|
||||||
"Hash": 256,
|
"Hash": 256,
|
||||||
# Default size is 16 MB. It's recommended that you increase this value, but keep it
|
# Default size is 16 MB. It's recommended that you increase this value, but keep
|
||||||
# as some power of 2. E.g., if you're fine using 2 GB of RAM, set Hash to 2048
|
# it as some power of 2. E.g., if you're fine using 2 GB of RAM, set Hash to
|
||||||
# (11th power of 2).
|
# 2048 (11th power of 2).
|
||||||
"MultiPV": 1,
|
"MultiPV": 1,
|
||||||
"Skill Level": 20,
|
"Skill Level": 20,
|
||||||
"Move Overhead": 10,
|
"Move Overhead": 10,
|
||||||
|
@ -32,9 +31,7 @@ settings = { # TODO Move to a config file
|
||||||
# "NNUE": "true", # TODO Find out if NNUE can be used with the python wrapper
|
# "NNUE": "true", # TODO Find out if NNUE can be used with the python wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
class BlunderEvaluator:
|
def __init__(self, engine_settings: dict = default_engine_settings):
|
||||||
|
|
||||||
def __init__(self, engine_settings: dict):
|
|
||||||
self.engine = Stockfish("/usr/bin/stockfish")
|
self.engine = Stockfish("/usr/bin/stockfish")
|
||||||
self.settings = engine_settings
|
self.settings = engine_settings
|
||||||
self.engine.update_engine_parameters(self.settings)
|
self.engine.update_engine_parameters(self.settings)
|
||||||
|
@ -49,7 +46,7 @@ class BlunderEvaluator:
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.engine.set_position()
|
self.engine.set_position()
|
||||||
|
|
||||||
def make_move(self, move) -> None:
|
def move(self, move) -> None:
|
||||||
"""
|
"""
|
||||||
Makes a move on the board and updates the game state
|
Makes a move on the board and updates the game state
|
||||||
:param move: str
|
:param move: str
|
||||||
|
@ -64,7 +61,8 @@ class BlunderEvaluator:
|
||||||
print(self.current_wdl)
|
print(self.current_wdl)
|
||||||
print(self.current_evaluation)
|
print(self.current_evaluation)
|
||||||
if self.move_was_blunder():
|
if self.move_was_blunder():
|
||||||
# If the played move was a blunder play a random sound from the blunder path
|
# If the played move was a blunder play a random sound from the blunder
|
||||||
|
# path
|
||||||
self.play_sound("blunder")
|
self.play_sound("blunder")
|
||||||
print("Blunder!")
|
print("Blunder!")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue