forked from NicoGol/pontu_game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
agent.py
62 lines (49 loc) · 1.55 KB
/
agent.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import minimax
"""
Class that represents a agent.
"""
class Agent():
"""
Compute the action to perfom on the current state
of the game. The must be compute in at most time_left
seconds.
state: the current state
time_left: the number of second left
"""
def get_action(self, state, last_action, time_left):
abstract
def get_name(self):
return 'student agent'
"""
Set the id of the agent in the game. In a two player
game it will be either 0 if we play first of 1 otherwise.
"""
def set_id(self, id):
self.id = id
"""
Alpha beta agent.
"""
class AlphaBetaAgent(Agent):
"""This is the skeleton of an agent."""
def get_action(self, state, last_action, time_left):
"""This function is used to play a move according
to the board, player and time left provided as input.
It must return an action representing the move the player
will perform.
"""
return minimax.search(state, self)
def successors(self, state):
"""The successors function must return (or yield) a list of
pairs (a, s) in which a is the action played to reach the
state s;"""
abstract
def cutoff(self, state, depth):
"""The cutoff function returns true if the alpha-beta/minimax
search has to stop; false otherwise.
"""
abstract
def evaluate(self, state):
"""The evaluate function must return an integer value
representing the utility function of the board.
"""
abstract