Move files into chesspp module

This commit is contained in:
2024-01-27 21:08:37 +01:00
parent 17e5bebd88
commit 69aa9ce2d9
10 changed files with 9 additions and 9 deletions

51
chesspp/i_mcts.py Normal file
View File

@@ -0,0 +1,51 @@
import chess
from abc import ABC, abstractmethod
from i_strategy import IStrategy
from typing import Dict
class IMcts(ABC):
def __init__(self, board: chess.Board, strategy: IStrategy):
self.board = board
@abstractmethod
def sample(self, runs: int = 1000) -> None:
"""
Run the MCTS simulation
:param runs: number of runs
:return:
"""
pass
@abstractmethod
def apply_move(self, move: chess.Move) -> None:
"""
Apply the move to the chess board
:param move: move to apply
:return:
"""
pass
@abstractmethod
def get_children(self) -> list['IMcts']:
"""
Return the immediate children of the root node
:return: list of immediate children of mcts root
"""
pass
@abstractmethod
def get_moves(self) -> Dict[chess.Move, int]:
"""
Return all legal moves from this node with respective scores
:return: dictionary with moves as key and scores as values
"""
pass
"""
TODO: add score class:
how many moves until the end of the game?
score ranges?
perspective of white/black
"""