本文整理汇总了Python中actions.Actions.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.extend方法的具体用法?Python Actions.extend怎么用?Python Actions.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actions.Actions
的用法示例。
在下文中一共展示了Actions.extend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoadFromConfig
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import extend [as 别名]
class Universe:
DEBUG_MOVE = False
DEBUG_SUBSIST = False
DEBUG_ENERGY = False
DEBUG_DISCOVER = False
DEBUG_LEARN = False
DEBUG_TEACH = False
DEBUG_LEACH = False
def LoadFromConfig(self):
# none of these vary during the game:
self.energyTypes = self.config.GetEnergyTypes()
self.cells = self.config.GetInitialCells()
self.subsistEnergyRequirements = self.config.GetSubsistEnergyRequirements()
self.moveEnergyRequirements = self.config.GetMoveEnergyRequirements()
self.__DefaultGatherEfficencies = self.config.GetDefaultGatherEfficencies()
self.__DefaultMovementRate = self.config.GetDefaultMovementRate()
self.__DefaultTeachingMultiplier = self.config.GetDefaultTeachingMultiplier()
self.__DefaultLeachingTargetRate = self.config.GetDefaultLeachingTargetRate()
self.__DefaultLeachingPowers = self.config.GetDefaultLeachingPowers()
self.__DefaultLeachingDefenses = self.config.GetDefaultLeachingDefenses()
self.__DefaultLeachingEfficencies = self.config.GetDefaultLeachingEfficencies()
self.Advancements = self.config.GetAdvancements()
self.actions = Actions(self)
def LoadNew(self, configFileName):
f = open(configFileName)
jsonString = f.read()
f.close()
self.config = Config.FromJson(jsonString, self)
self.LoadFromConfig()
# the following vary during the game:
self.entities = self.config.GetInitialEntities(self.cells)
self.t = 1
self.__initTeams()
def ToJson(self):
return json.dumps({
'config': self.config.ToJson(),
'entities': [entity.ToJson() for entity in self.entities],
't': self.t})
@staticmethod
def FromJson(jsonString):
universe = Universe()
universe.ReinitFromJson(jsonString)
return universe
def __initTeams(self):
self.__teams = set()
for entity in self.entities:
self.__teams.add(entity.Team.lower())
self.__teamsAccountedFor = set()
def ReinitFromJson(self, jsonString):
d = json.loads(jsonString)
self.config = Config.FromJson(d['config'], self)
self.LoadFromConfig()
cellDict = dict()
for cell in self.cells:
cellDict[cell.Name] = cell
self.entities = [Entity.FromJson(jsonString, self, cellDict) for jsonString in d['entities']]
self.t = d['t']
self.__initTeams()
def GetDefaultGatherEfficencies(self):
return copy.deepcopy(self.__DefaultGatherEfficencies)
def GetDefaultMovementRate(self):
return copy.deepcopy(self.__DefaultMovementRate)
def GetDefaultTeachingMultiplier(self):
return self.__DefaultTeachingMultiplier
def GetDefaultLeachingTargetRate(self):
return self.__DefaultLeachingTargetRate
def GetDefaultLeachingPowers(self):
return copy.deepcopy(self.__DefaultLeachingPowers)
def GetDefaultLeachingDefenses(self):
return copy.deepcopy(self.__DefaultLeachingDefenses)
def GetDefaultLeachingEfficencies(self):
return copy.deepcopy(self.__DefaultLeachingEfficencies)
def DoTimeStep(self):
self.actions.DoGather()
#transfer
self.actions.DoSplit()
self.actions.DoDiscover()
self.actions.DoTeach()
#unlearn
self.actions.DoLeach()
self.actions.DoMove()
self.actions.DoSubsist()
self.actions = Actions(self)
self.__teamsAccountedFor = set()
self.t+=1
def ActTryTimestep(self, actions, team):
self.actions.extend(actions)
#.........这里部分代码省略.........