mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 14:43:01 +02:00
18 lines
386 B
Python
18 lines
386 B
Python
import random
|
|
from typing import Optional
|
|
|
|
import chess
|
|
|
|
|
|
class RandomEngine:
|
|
"""Picks a random legal move.
|
|
|
|
You can replace this with a UCI engine wrapper or a better search.
|
|
"""
|
|
|
|
def choose_move(self, board: chess.Board) -> Optional[chess.Move]:
|
|
moves = list(board.legal_moves)
|
|
if not moves:
|
|
return None
|
|
return random.choice(moves)
|