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


Python VGDLParser.buildLevel方法代码示例

本文整理汇总了Python中vgdl.core.VGDLParser.buildLevel方法的典型用法代码示例。如果您正苦于以下问题:Python VGDLParser.buildLevel方法的具体用法?Python VGDLParser.buildLevel怎么用?Python VGDLParser.buildLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vgdl.core.VGDLParser的用法示例。


在下文中一共展示了VGDLParser.buildLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test4

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def test4():
    from numpy import ndarray
    from examples.gridphysics.mazes import polarmaze_game
    from pybrain.optimization import SNES, WeightGuessing
    g = VGDLParser().parseGame(polarmaze_game)
    g.buildLevel(labyrinth2)
    game_env = GameEnvironment(g)
    net = buildNet(game_env.outdim, 5, 4, temperature=0.1, recurrent=False)
    
    algo = SNES(lambda x: someEpisodes(game_env, x, avgOver=3), net, verbose=True, desiredEvaluation=0.75)
    #algo = WeightGuessing(lambda x: someEpisodes(game_env, x), net, verbose=True, desiredEvaluation=0.78)
    rows, cols = 2,2
    episodesPerStep = 4
    for i in range(rows*cols):
        pylab.subplot(rows, cols, i+1)
        algo.learn(episodesPerStep)
        if isinstance(algo.bestEvaluable, ndarray):
            net._setParameters(algo.bestEvaluable)
        else:
            net = algo.bestEvaluable
        plotBackground(game_env)    
        plotTrajectories(game_env, net)
        pylab.title(str((i+1)*episodesPerStep))
        if algo.desiredEvaluation <= algo.bestEvaluation:
            break
        print
    pylab.show()
开发者ID:chongdashu,项目名称:py-vgdl,代码行数:29,代码来源:nomodel_pomdp.py

示例2: testAugmented

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testAugmented():
    from vgdl.core import VGDLParser
    from pybrain.rl.experiments.episodic import EpisodicExperiment
    from vgdl.mdpmap import MDPconverter
    from vgdl.agents import PolicyDrivenAgent
    
    
    zelda_level2 = """
wwwwwwwwwwwww
wA wwk1ww   w
ww  ww    1 w
ww     wwww+w
wwwww1ww  www
wwwww  0  Gww
wwwwwwwwwwwww
"""

    
    from examples.gridphysics.mazes.rigidzelda import rigidzelda_game
    g = VGDLParser().parseGame(rigidzelda_game)
    g.buildLevel(zelda_level2)
    env = GameEnvironment(g, visualize=False,
                          recordingEnabled=True, actionDelay=150)
    C = MDPconverter(g, env=env, verbose=True)
    Ts, R, _ = C.convert()
    print C.states
    print Ts[0]
    print R
    env.reset()
    agent = PolicyDrivenAgent.buildOptimal(env)
    env.visualize = True
    env.reset()
    task = GameTask(env)    
    exper = EpisodicExperiment(task, agent)
    exper.doEpisodes(1)
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:37,代码来源:interfaces.py

示例3: test6

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def test6():
    """ Now with memory!"""
    from numpy import ndarray
    from examples.gridphysics.mazes import polarmaze_game
    from pybrain.optimization import SNES
    g = VGDLParser().parseGame(polarmaze_game)
    g.buildLevel(cheese_maze)
    game_env = GameEnvironment(g)
    net = buildNet(game_env.outdim, 10, 4, temperature=0.1, recurrent=True)
    
    algo = SNES(lambda x: someEpisodes(game_env, x, avgOver=6, maxSteps=30, exploretoo=False), net, verbose=True, desiredEvaluation=0.85)
    print algo.batchSize
    rows, cols = 2,3
    episodesPerStep = 5
    for i in range(rows*cols):
        pylab.subplot(rows, cols, i+1)
        algo.learn(episodesPerStep)
        if isinstance(algo.bestEvaluable, ndarray):
            net._setParameters(algo.bestEvaluable)
        else:
            net = algo.bestEvaluable
        plotBackground(game_env)    
        plotTrajectories(game_env, net)
        pylab.title(str((i+1)*episodesPerStep))
        if algo.desiredEvaluation <= algo.bestEvaluation:
            break
        print
    pylab.show()
开发者ID:chongdashu,项目名称:py-vgdl,代码行数:30,代码来源:nomodel_pomdp.py

示例4: plotLSPIValues

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def plotLSPIValues(gametype, layout, discountFactor=0.9, useTD=False, showValue=False):
    # build the game
    g = VGDLParser().parseGame(gametype)
    g.buildLevel(layout)
    
    # transform into an MDP and the mapping to observations
    C = MDPconverter(g)
    Ts, R, fMap = C.convert()    
    
    # find the the best least-squares approximation to the policy,
    # given only observations, not the state information
    if useTD:
        # state-based
        _, Tlspi = LSTD_PI_policy(fMap, Ts, R, discountFactor=discountFactor)
    else:
        # state-action-based
        _, Tlspi = LSPI_policy(fMap, Ts, R, discountFactor=discountFactor)
    
    # evaluate the policy
    Vlspi = trueValues(Tlspi, R, discountFactor=discountFactor)
        
    # plot those values    
    featurePlot((g.width, g.height), C.states, Vlspi)
    
    if showValue:
        # expected discounted reward at initial state
        Vinit = Vlspi[C.initIndex()]
        pylab.xlabel("V0=%.4f"%Vinit)
开发者ID:chongdashu,项目名称:py-vgdl,代码行数:30,代码来源:model_pomdp.py

示例5: testRollout

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testRollout(actions=[0, 0, 2, 2, 0, 3] * 20):        
    from examples.gridphysics.mazes import polarmaze_game, maze_level_1
    from vgdl.core import VGDLParser
    game_str, map_str = polarmaze_game, maze_level_1
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)    
    env = GameEnvironment(g, visualize=True, actionDelay=100)
    env.rollOut(actions)
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:10,代码来源:interfaces.py

示例6: testRolloutVideo

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testRolloutVideo(actions=[0, 0, 2, 2, 0, 3] * 2):        
    from examples.gridphysics.mazes import polarmaze_game, maze_level_1
    from vgdl.core import VGDLParser
    from vgdl.tools import makeGifVideo
    game_str, map_str = polarmaze_game, maze_level_1
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)
    makeGifVideo(GameEnvironment(g, visualize=True), actions)
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:10,代码来源:interfaces.py

示例7: _createVGDLGame

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def _createVGDLGame( gameSpec, levelSpec ):
    import uuid
    from vgdl.core import VGDLParser
    # parse, run and play.
    game = VGDLParser().parseGame(gameSpec)
    game.buildLevel(levelSpec)
    game.uiud = uuid.uuid4()
    return game
开发者ID:dylski,项目名称:py-vgdl,代码行数:10,代码来源:rlenvironment.py

示例8: testLoadSave

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testLoadSave():
    from vgdl.core import VGDLParser
    from examples.gridphysics.aliens import aliens_level, aliens_game
        
    map_str, game_str = aliens_level, aliens_game
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)
    
    for _ in range(1000):
        s = g.getFullState()
        g.setFullState(s)
开发者ID:chongdashu,项目名称:py-vgdl,代码行数:13,代码来源:speed_test.py

示例9: test2

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def test2():
    from examples.gridphysics.mazes import polarmaze_game, maze_level_1
    from vgdl.core import VGDLParser
    game_str, map_str = polarmaze_game, maze_level_1
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)    
    actions = [1, 0, 0, 3, 0, 2, 0, 2, 0, 0, 0]
    env = GameEnvironment(g, visualize=True, actionDelay=100)
    env.rollOut(actions)
    env.reset()
    senv = SubjectiveGame(g, actionDelay=1500)
    senv.rollOut(actions)
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:14,代码来源:subjective.py

示例10: testStochMaze

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testStochMaze():
    from vgdl.core import VGDLParser
    from examples.gridphysics.mazes.stochastic import stoch_game, stoch_level
    g = VGDLParser().parseGame(stoch_game)
    g.buildLevel(stoch_level)
    C = MDPconverter(g, verbose=True)
    Ts, R, fMap = C.convert()
    print C.states
    print R
    for T in Ts:
        print T
    print fMap
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:14,代码来源:mdpmap.py

示例11: testMaze

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testMaze():
    from vgdl.core import VGDLParser
    from examples.gridphysics.mazes import polarmaze_game, maze_level_1
    game_str, map_str = polarmaze_game, maze_level_1
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)
    C = MDPconverter(g, verbose=True)
    Ts, R, fMap = C.convert()
    print C.states
    print R
    for T in Ts:
        print T
    print fMap
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:15,代码来源:mdpmap.py

示例12: test4

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def test4():
    """ Same thing, but animated. """
    from examples.gridphysics.mazes.windy import windy_stoch_game, windy_level
    from pybrain.rl.experiments.episodic import EpisodicExperiment
    from vgdl.interfaces import GameEnvironment, GameTask
    from vgdl.agents import PolicyDrivenAgent 
    g = VGDLParser().parseGame(windy_stoch_game)
    g.buildLevel(windy_level)
    env = GameEnvironment(g, visualize=True, actionDelay=100)
    task = GameTask(env)
    agent = PolicyDrivenAgent.buildOptimal(env)
    exper = EpisodicExperiment(task, agent)
    res = exper.doEpisodes(5)
    print res
开发者ID:chongdashu,项目名称:py-vgdl,代码行数:16,代码来源:model_mdp.py

示例13: test1

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def test1():
    from examples.gridphysics.mazes import polarmaze_game, maze_level_1    
    
    game_str, map_str = polarmaze_game, maze_level_1
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)
    
    game_env = GameEnvironment(g)
    print 'number of observations:', game_env.outdim
    
    net = buildNet(game_env.outdim, 2, 2)
    for i in range(200):
        net.randomize()
        net.reset()
        print someEpisodes(game_env, net),
        if i% 20 == 19:
            print
开发者ID:chongdashu,项目名称:py-vgdl,代码行数:19,代码来源:nomodel_pomdp.py

示例14: testPolicyAgent

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def testPolicyAgent():
    from pybrain.rl.experiments.episodic import EpisodicExperiment
    from vgdl.core import VGDLParser
    from examples.gridphysics.mazes import polarmaze_game, maze_level_2
    from vgdl.agents import PolicyDrivenAgent
    game_str, map_str = polarmaze_game, maze_level_2
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)
    
    env = GameEnvironment(g, visualize=False, actionDelay=100)
    task = GameTask(env)
    agent = PolicyDrivenAgent.buildOptimal(env)
    env.visualize = True
    env.reset()
    exper = EpisodicExperiment(task, agent)
    res = exper.doEpisodes(2)
    print res
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:19,代码来源:interfaces.py

示例15: test3

# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import buildLevel [as 别名]
def test3():
    from examples.gridphysics.mazes import polarmaze_game
    from examples.gridphysics.mazes.simple import maze_level_1b
    from vgdl.core import VGDLParser
    from pybrain.rl.experiments.episodic import EpisodicExperiment
    from vgdl.interfaces import GameTask
    from vgdl.agents import InteractiveAgent, UserTiredException
    game_str, map_str = polarmaze_game, maze_level_1b
    g = VGDLParser().parseGame(game_str)
    g.buildLevel(map_str)    
    senv = SubjectiveGame(g, actionDelay=100, recordingEnabled=True)
    #senv = GameEnvironment(g, actionDelay=100, recordingEnabled=True, visualize=True)
    task = GameTask(senv)    
    iagent = InteractiveAgent()
    exper = EpisodicExperiment(task, iagent)
    try:
        exper.doEpisodes(1)
    except UserTiredException:
        pass
    print senv._allEvents
开发者ID:sarobe,项目名称:VGDLEntityCreator,代码行数:22,代码来源:subjective.py


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