当前位置: 首页>>代码示例>>Python>>正文


Python Actions.returnFunctions方法代码示例

本文整理汇总了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):
#.........这里部分代码省略.........
开发者ID:JaydenIvanovic,项目名称:capture-the-flag,代码行数:103,代码来源:mycmd.py


注:本文中的actions.Actions.returnFunctions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。