加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
template.py 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
ZHUOYA ZHOU 提交于 2022-10-06 18:32 . Add files via upload
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化