system's picture
system HF Staff
Deploy from 1040f46
a5f2e46 verified
Raw
History Blame Contribute Delete
789 Bytes
import chess
import random
class RandomBot:
def __init__(self):
pass
def predict(self, board: chess.Board) -> chess.Move:
legal_moves = list(board.legal_moves)
if not legal_moves:
raise ValueError("No legal moves available.")
# pick a random move
move = random.choice(legal_moves)
return move.uci(), None
if __name__ == "__main__":
bot = RandomBot()
board = chess.Board()
print("Initial board:")
print(board)
move = bot.predict(board)
print(f"RandomBot suggests move: {move}")
board.push(move)
print("Board after move:")
print(board)
move = bot.predict(board)
print(f"RandomBot suggests move: {move}")
board.push(move)
print("Board after move:")
print(board)