本文整理汇总了Python中layout.getLayout方法的典型用法代码示例。如果您正苦于以下问题:Python layout.getLayout方法的具体用法?Python layout.getLayout怎么用?Python layout.getLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类layout
的用法示例。
在下文中一共展示了layout.getLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getRandomPositions
# 需要导入模块: import layout [as 别名]
# 或者: from layout import getLayout [as 别名]
def getRandomPositions(args, mapName):
args["layout"] = layout.getLayout(mapName + ".lay", args["numAgents"])
示例2: readCommand
# 需要导入模块: import layout [as 别名]
# 或者: from layout import getLayout [as 别名]
def readCommand(param, prefix=None, level=None):
"""
Python CLI command line interface
param [map layout, pursuer, agent numbers, game numbers]
"""
import targetAgents as targets # target class
import pursuerAgents as pursuers # pursuer class
import graphicsDisplay as graphics # display class
# dictionary data structure for parameters
args = dict()
# default 1 target + 2 pursuers
args["numAgents"] = 3
if len(param) > 3:
args["numAgents"] = int(param[2])
# default 1 game
args["numGames"] = 1
if len(param) > 2:
args["numGames"] = int(param[3])
# map layout param[0]
args["layout"] = layout.getLayout("basicMap.lay", args["numAgents"])
if len(param) > 0:
args["layout"] = layout.getLayout(param[0] + ".lay", args["numAgents"])
# target algorithm
args["target"] = targets.SimpleFleeTarget()
# pursuer algorithm: param[1]
# default pursuer algorithm
# args["pursuers"] = [pursuers.SpeedUpCRAPursuer(prefix) for i in range(1, args["layout"].getNumPursuers() + 1)]
args["pursuers"] = None
if len(param) > 1:
if param[1] == "astar":
args["pursuers"] = [pursuers.AstarPursuer() for i in range(1, args["layout"].getNumPursuers() + 1)]
elif param[1] == "cra":
args["pursuers"] = [pursuers.CRAPursuer() for i in range(1, args["layout"].getNumPursuers() + 1)]
elif param[1] == "speedupcra":
args["pursuers"] = [pursuers.SpeedUpCRAPursuer(prefix) for i in range(1, args["layout"].getNumPursuers() + 1)]
elif param[1] == "abstraction":
# Map abstraction
abstraction = Abstraction(1)
abstraction.getAbstractMap(args["layout"].obstacles)
abstractions = []
abstractions.append(abstraction)
if level > 1:
abstraction2 = Abstraction(2)
abstraction2.levelUp(abstraction.nodes[0])
abstractions.append(abstraction2)
if level > 2:
abstraction3 = Abstraction(3)
abstraction3.levelUp(abstraction2.nodes[0])
abstractions.append(abstraction3)
args["pursuers"] = [pursuers.AbstractCoverPursuer(abstractions, prefix) for i in range(1, args["layout"].getNumPursuers() + 1)]
# graphic display
args["display"] = graphics.MultiAgentGraphics()
return args
示例3: gameUpdate
# 需要导入模块: import layout [as 别名]
# 或者: from layout import getLayout [as 别名]
def gameUpdate(graphics):
global game , play, pacbot, lay , restart
# display start postions
# display_game(game.pacbot,game.red,game.pink,game.orange,game.blue,game.score,game.lives,game.state,game.grid)
if game.grid[game.pacbot.pos[0]][game.pacbot.pos[1]] == o:
game.grid[game.pacbot.pos[0]][game.pacbot.pos[1]] = e
game.score += 10
while session:
if game.respawn:
mode_changed = True
while mode_changed:
lock.acquire()
try:
game.respawn = False
mode_changed = False
finally:
lock.release()
graphics.update(game.gstate)
# scatter_no = 0
# scatter_on()
if game.play:
position = botTracker.get_bot_location()
direction = botTracker.get_bot_direction()
lock.acquire()
try:
pacbot.update(position, direction)
game.game_go(pacbot, False)
finally:
lock.release()
graphics.update(game.gstate)
elif restart:
restart = False
mode_changed = True
while mode_changed:
lock.acquire()
try:
lay = layout.getLayout("pacbotLayout.lay")
pacbot = PacBot((23,13), "right")
game = GameState(copy.deepcopy(grid), lay, pacbot)
graphics = PacmanGraphics(0.95)
graphics.initialize(game.gstate)
graphics.update(game.gstate)
mode_changed = False
finally:
lock.release()
# scatter_no = 0
# scatter_on()