Added cli parameters for simulation test

This commit is contained in:
Theo Haslinger
2024-01-29 20:26:16 +01:00
committed by DarkCider
parent b9761e1e2b
commit 86da09abcf
3 changed files with 65 additions and 10 deletions

View File

@@ -43,8 +43,9 @@ class Evaluation:
self.strategy_b = strategy_b
self.limit = limit
def run(self, n_games=100) -> List[EvaluationResult]:
with mp.Pool(mp.cpu_count()) as pool:
def run(self, n_games=100, proc=mp.cpu_count()) -> List[EvaluationResult]:
proc = min(proc, mp.cpu_count())
with mp.Pool(proc) as pool:
args = [(self.engine_a, self.strategy_a, self.engine_b, self.strategy_b, self.limit) for i in range(n_games)]
return pool.map(Evaluation._test_simulate, args)

View File

@@ -9,8 +9,9 @@ _DIR = os.path.abspath(os.path.dirname(__file__))
class StockFishStrategy(IStrategy):
def __init__(self):
def __init__(self, path="../stockfish/stockfish-windows-x86-64-avx2"):
self._stockfish = None
self.path = path
def __del__(self):
if self._stockfish is not None:
@@ -20,7 +21,7 @@ class StockFishStrategy(IStrategy):
def stockfish(self) -> chess.engine.SimpleEngine:
if self._stockfish is None:
self._stockfish = self.stockfish = chess.engine.SimpleEngine.popen_uci(
os.path.join(_DIR, "../stockfish/stockfish-ubuntu-x86-64-avx2"))
os.path.join(_DIR, self.path))
return self._stockfish
@stockfish.setter