forked from COMP90054-2021S2/example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.py
More file actions
84 lines (61 loc) · 2.04 KB
/
Copy pathtemplate.py
File metadata and controls
84 lines (61 loc) · 2.04 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import utils
import random
class GameState:
def __init__(self,num_of_agent,agent_id):
pass
class Action:
pass
class GameRule:
def __init__(self, num_of_agent = 2):
self.current_agent_index = 0
self.num_of_agent = num_of_agent
self.current_game_state = self.initialGameState()
self.action_counter = 0
def initialGameState(self):
utils.raiseNotDefined()
return 0
def generateSuccessor(self, game_state, action, agent_id):
utils.raiseNotDefined()
return 0
def getNextAgentIndex(self):
return (self.current_agent_index + 1) % self.num_of_agent
def getLegalActions(self, game_state, agent_id):
utils.raiseNotDefined()
return []
def calScore(self, game_state,agent_id):
utils.raiseNotDefined()
return 0
def gameEnds(self):
utils.raiseNotDefined()
return False
def update(self, action):
temp_state = self.current_game_state
self.current_game_state = self.generateSuccessor(temp_state, action, self.current_agent_index)
self.current_agent_index = self.getNextAgentIndex()
self.action_counter += 1
def getCurrentAgentIndex(self):
return self.current_agent_index
class Agent(object):
def __init__(self, _id):
self.id = _id
super().__init__()
# Given a set of available actions for the agent to execute, and
# a copy of the current game state (including that of the agent),
# select one of the actions to execute.
def SelectAction(self, actions, game_state):
return random.choice(actions)
class Displayer:
def __init__(self):
pass
# show the displayer for the first time
def InitDisplayer(self,runner):
pass
def ExcuteAction(self,i,move,game_state):
utils.raiseNotDefined()
pass
def TimeOutWarning(self,runner,id):
utils.raiseNotDefined()
pass
def EndGame(self,game_state,scores):
utils.raiseNotDefined()
pass