本文整理匯總了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()