本文整理汇总了Python中actions.Actions.returnFunctions方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.returnFunctions方法的具体用法?Python Actions.returnFunctions怎么用?Python Actions.returnFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actions.Actions
的用法示例。
在下文中一共展示了Actions.returnFunctions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RLCommander
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import returnFunctions [as 别名]
class RLCommander(Commander):
"""
Rename and modify this class to create your own commander and add
mycmd.Placeholder to the execution command you use to run the
competition.
"""
#LEARNING_PATH = '/media/jayden/Storage/Linux/AIGameDev/CaptureTheFlag/aisbx-0.20.6.linux-x86_64/'
LEARNING_PATH = '/home/jayden/AIGameDev/CaptureTheFlag/aisbx-0.20.5.linux-x86_64/'
def initialize(self):
"""
Use this function to setup your bot before the game starts.
"""
self.verbose = True #display the command descriptions next to the bot.
#Get the important game data to represent the current state.
self.gameData = GameData(self.game, self.level)
#Get important data for each bot to represent the current state.
self.bots = [BotData(name, self.game, self.level) for name in\
[bot.name for bot in self.game.team.members]]
self.actions = Actions(self.game, self.level, self)
#Set up reinforcement learning.
self.agent = CTFAgent()
self.env = CTFEnvironment(self.actions.returnFunctions(), self.gameData,
self.bots, [bot for bot in self.game.team.members])
self.rl = RLinterface(self.agent, self.env)
self.checkForPastLearning() #Check for previous learning.
self.rl.RL_start() #Start episode.
self.tc = 0 #Count until reinforcement learning begins. Get bots out of spawn...
print 'Finished Commander Initialization...'
def tick(self):
"""
Override this function for your own bots.
Here you can access all the information in self.game,
which includes game information, and self.level which includes
information about the level.
"""
#if self.tc % 10 == 0:
self.updateGameState()
#self.gameData.printProperties()
#print '\n\n\n'
self.runRL()
self.tc += 1
def shutdown(self):
"""
Use this function to teardown your bot after the game is over,
or perform an analysis of the data accumulated during the game.
"""
print 'Writing out State Action Values...'
self.agent.sendToFile_QValues()
#self.agent.sendToFile_ActionValues()
print 'Fin.'
######################################################################
#Utility
######################################################################
def printStars(self):
"""
Print stars for formatting output nicely.
"""
print '*' * 80
def updateGameState(self):
"""
Update the data structures with the new information.
"""
self.gameData.updateGameState(self.game)
for bot in self.bots:
bot.updateGameState(self.game, self.level)
def printStateProperties(self):
"""
Print the value of all the properties of our state.
"""
self.printStars()
print 'Game Properties'
self.printStars()
self.gameData.printProperties()
self.printStars()
print 'Bot Properties'
for bot in self.bots:
self.printStars()
bot.printProperties()
self.printStars()
print '\n\n\n'
def checkForPastLearning(self):
#.........这里部分代码省略.........