-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasePlayer.py
executable file
·39 lines (33 loc) · 1.52 KB
/
basePlayer.py
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
import random
from gomoku import Move, GameState
from GmUtils import GmUtils
# This default base player does a randomn move
class basePlayer:
"""This class specifies a player that just does random moves.
The use of this class is two-fold: 1) You can use it as a base random roll-out policy.
2) it specifies the required methods that will be used by the competition to run
your player
"""
def __init__(self, black_: bool = True):
"""Constructor for the player."""
self.black = black_
def new_game(self, black_: bool):
"""At the start of each new game you will be notified by the competition.
this method has a boolean parameter that informs your agent whether you
will play black or white.
"""
self.black = black_
def move(
self, state: GameState, last_move: Move, max_time_to_move: int = 1000
) -> Move:
"""This is the most important method: the agent will get:
1) the current state of the game
2) the last move by the opponent
3) the available moves you can play (this is a special service we provide ;-) )
4) the maximum time until the agent is required to make a move in milliseconds [diverging from this will lead to disqualification].
"""
moves = GmUtils.getValidMoves(state[0], state[1])
return random.choice(moves)
def id(self) -> str:
"""Please return a string here that uniquely identifies your submission e.g., "name (student_id)" """
return "random_player"