-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathrandom_agent.py
More file actions
40 lines (32 loc) · 1.12 KB
/
random_agent.py
File metadata and controls
40 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import numpy as np
from agents.agent import Agent
from helpers import random_move
from store import register_agent
# Important: you should register your agent with a name
@register_agent("random_agent")
class RandomAgent(Agent):
"""
Example of an agent which takes random decisions
"""
def __init__(self):
super(RandomAgent, self).__init__()
self.name = "RandomAgent"
self.autoplay = True
def step(self, chess_board, player, opponent):
"""
Randomly selects a valid position to place a disc.
Parameters
----------
chess_board : numpy.ndarray of shape (board_size, board_size)
The chess board with 0 representing an empty space, 1 for black (Player 1),
and 2 for white (Player 2).
player : int
The current player (1 for black, 2 for white).
opponent : int
The opponent player (1 for black, 2 for white).
Returns
-------
move_pos : tuple of int
The position (x, y) where the player places the disc.
"""
return random_move(chess_board, player)