當前位置: 首頁>>代碼示例>>Python>>正文


Python layout.getLayout方法代碼示例

本文整理匯總了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"]) 
開發者ID:namidairo777,項目名稱:xiao_multiagent,代碼行數:4,代碼來源:multiAgent.py

示例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 
開發者ID:namidairo777,項目名稱:xiao_multiagent,代碼行數:60,代碼來源:multiAgent.py

示例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() 
開發者ID:HarvardURC,項目名稱:Pacbot,代碼行數:60,代碼來源:pacman.py


注:本文中的layout.getLayout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。