本文整理汇总了Python中vgdl.core.VGDLParser.playGame方法的典型用法代码示例。如果您正苦于以下问题:Python VGDLParser.playGame方法的具体用法?Python VGDLParser.playGame怎么用?Python VGDLParser.playGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vgdl.core.VGDLParser
的用法示例。
在下文中一共展示了VGDLParser.playGame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_game
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
def load_game(module_str, level_str):
module = importlib.import_module(module_str)
game = None
level = None
for key in module.__dict__.keys():
#print key
if(key.endswith("game")):
game = module.__dict__[key]
if(key.endswith("level") and key == level_str):
level = module.__dict__[key]
if(level is None):
return None
#print game, level
g = VGDLParser.playGame(game, level, headless = True, persist_movie = True, movie_dir = "./tmp/")
#g.startGameExternalPlayer(headless = True, persist_movie = True)
return g
示例2:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
moving >
avatar > MovingAvatar
bee > RandomNPC speed=1 cooldown=3 color=YELLOW
zombie > Chaser stype=avatar cooldown=6 speed=0.5 color=BROWN
InteractionSet
honey avatar > collectResource scoreChange=1
honey avatar > killSprite
moving wall > stepBack
avatar zombie > killIfHasLess resource=honey limit=1 scoreChange=-1
avatar zombie > changeResource resource=honey value=-1
zombie avatar > killSprite
bee zombie > transformTo stype=honey
zombie bee > killSprite
avatar hell > killSprite
TerminationSet
Timeout limit=1000 win=True
SpriteCounter stype=avatar limit=0 win=False
LevelMapping
0 > flower
1 > hell
. > honey
2 > zombie
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(zombie_game, zombie_level)
示例3:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
moving elevator > pullWithIt
elevator EOS > wrapAround
LevelMapping
G > goal
1 > goomba
2 > paratroopa
= > elevator
"""
mario_level = """
wwwwwwwwwwwwwwwwwwwwwwwwwwww
w w
w G1w
w === wwww
w 1 w
w w 2 ww w
w wwwwwww w
w w
w w
w 2 2 w
w www wwwwww w
w A 1 === w
wwww wwww 2 w
wwwwwwwwww wwww w
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(mario_game, mario_level)
示例4:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
w.wwww.ww.wwwwwwww.ww.wwww.w
w.wwww.ww.wwwwwwww.ww.wwww.w
w......ww....ww....ww......w
wwwwww.wwwww ww wwwww.wwwwww
wwwwww.wwwww ww wwwww.wwwwww
wwwwww.ww ww.wwwwww
wwwwww.ww ww.wwwwww
wwwwww.ww www www ww.wwwwww
. ww1234ww .
wwwwww.ww wwwwwwww ww.wwwwww
wwwwww.ww ww.wwwwww
wwwwww.ww ww.wwwwww
wwwwww.ww wwwwwwww ww.wwwwww
wwwwww.ww wwwwwwww ww.wwwwww
w............ww............w
w.wwww.wwwww.ww.wwwww.wwww.w
w0wwww.wwwww.ww.wwwww.wwww0w
w...ww.......A........ww...w
www.ww.ww.wwwwwwww.ww.ww.www
www.ww.ww.wwwwwwww.ww.ww.www
w......ww....ww....ww......w
w.wwwwwwwwww.ww.wwwwwwwwww.w
w.wwwwwwwwww.ww.wwwwwwwwww.w
w..........................w
wwwwwwwwwwwwwwwwwwwwwwwwwwww
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(pacman_game, pacman_level)
示例5:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
normal infected > transformTo stype=carrier
host infected > transformTo stype=infected
normal virus > transformTo stype=carrier
host virus > transformTo stype=infected
guardian virus > killSprite
LevelMapping
1 > guardian
0 > host
X > virus
A > normal
"""
chase_level = """
wwwwwwwwwwwwwwwwwwwwwwwwwwww
www 0 w w 0 www 0w0 w
w 1 w X w 0w
w 0 0 w A w0 w
w wwwwwwww 0 w
w0 ww wwww
w 0 1 w w X w
w0 w wwwww wX w 10w
wwww wwX 1 Xw
wwww 0 0 0 www 0 Xww
wwwwwwwwwwwwwwwwwwwwwwwwwwww
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(infection_game, chase_level)
示例6:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
w w 0 w
w 1 ww
w ww
wwwwwwwwwwwww
"""
push_game = """
BasicGame frame_rate=30
SpriteSet
hole > Immovable color=DARKBLUE
movable >
avatar > MovingAvatar cooldown=4
box > Passive
LevelMapping
0 > hole
1 > box
InteractionSet
avatar wall > stepBack
box avatar > bounceForward
box wall > undoAll
box box > undoAll
box hole > killSprite
TerminationSet
SpriteCounter stype=box limit=0 win=True
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(push_game, box_level)
示例7:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
goal > Immovable color=GREEN
mana > Resource color=LIGHTBLUE limit=3
bullet > Missile color=RED singleton=True
fire > Spreader color=ORANGE spreadprob=0.25
avatar > ShootAvatar ammo=mana stype=bullet
InteractionSet
mana avatar > collectResource scoreChange=5
mana avatar > killSprite
avatar wall > stepBack
goal avatar > killSprite scoreChange=100
avatar fire > killSprite
wall bullet > killSprite scoreChange=1
bullet wall > transformTo stype=fire
fire wall > killSprite
fire fire > killSprite
mana fire > killSprite
TerminationSet
SpriteCounter stype=avatar limit=0 win=False
SpriteCounter stype=goal limit=0 win=True
LevelMapping
G > goal
. > mana
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(caster_game, caster_level)
示例8: upload
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
"""
VGDL example: Same as frogs.py, but uploads video on youtube
@author: Tom Schaul, Spyridon Samothrakis
"""
from frogs import frog_level, frog_game
if __name__ == "__main__":
from vgdl.core import VGDLParser
from vgdl.youtube import upload
game = VGDLParser.playGame(frog_game, frog_level, persist_movie=True)
upload(game.video_file)
示例9: tmaze
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
@author: Tom Schaul
'''
from mazegames import commonmaze_game
polarTmaze_game = commonmaze_game +"""
avatar > RotatingAvatar
TerminationSet
SpriteCounter stype=goal limit=1 win=True
"""
Tmaze_game = commonmaze_game +"""
TerminationSet
SpriteCounter stype=goal limit=1 win=True
"""
def tmaze(length):
s = "wwwwwwwww\n"
s += "wG 4w2 Gw\n"
for _ in range(length-1):
s += "ww www ww\n"
s += "wm3www3mw\n"
s += "wwwwwwwww\n"
return s
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(polarTmaze_game, tmaze(4))
示例10:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
wall bullet > killSprite
bullet wall > killSprite
pad bullet > killSprite
avatar wall > stepBack
avatar EOS > stepBack
bullet EOS > killSprite
LevelMapping
G > pad
"""
artillery_level = """
wwwwwwwwwwwwwwwwwwwwww
w w w w
w www w
w w ww
w G w
w w w
w www w w
w wwwwwww www w
w ww w
w G w w
w ww G G w
wA wwwwww w
wwwwwwwwwwwwwwwwwwwwww
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(artillery_game, artillery_level)
示例11:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
SpriteCounter stype=avatar limit=0 win=False
MultiSpriteCounter stype1=goodies stype2=monster limit=0 win=True
InteractionSet
moving EOS > stepBack
weapon EOS > stepBack
moving wall > stepBack
avatar gold > stepBack
boulder wall > stepBack
monster wall > flipDirection
monster EOS > flipDirection
falling wall > killSprite
wall shovel > killSprite
gem avatar > killSprite
weapon avatar> killSprite
avatar monster > killSprite
monster boulder > killSprite
moving falling > killSprite
shovel shovel> transformTo stype=boulder
boulder wall > transformTo stype=resting
gold shovel > transformTo stype=falling
gold boulder > transformTo stype=falling
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(digdug_game, underground)
示例12:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
wall bullet > killSprite
bullet EOS > killSprite
tank wall > stepBack
tank EOS > stepBack
tank lift > conveySprite
LevelMapping
a > otheravatar
+ > liftup
- > pushdown
"""
tankwars_level = """
w w w
w w w w
w w w
w w w
w w
w w
w w w
w w w
w www w
w wwwwww w
w wwwwwwww w
wA wwwwwwwwwwwww aw
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(tankwars_game, tankwars_level)
示例13:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
wall > Immovable
InteractionSet
goal avatar > killSprite
avatar log > drownSafe
avatar log > pullWithIt # note how one collision can have multiple effects
avatar wall > stepBack
avatar water > drownSprite
avatar truck > killSprite
log EOS > killSprite
truck EOS > wrapAround
TerminationSet
SpriteCounter stype=goal limit=0 win=True
SpriteCounter stype=avatar limit=0 win=False
LevelMapping
G > goal
0 > water
1 > forest water # note how a single character can spawn multiple sprites
2 > forest wall log
- > slowtruck
x > fasttruck
= > log water
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(frog_game, frog_level)
示例14: range
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
s += "wGw\n"
for _ in range(length/2-2):
s += "w w\n"
s += "wAw\n"
s += "w4w\n"
s += "w1w\n"
s += "www\n"
return s
def ringworld(width):
assert width > 1
level = ["w"]*(width+2)+["\n"]
level += ["w"]+[" "]*width+["w\n"]
level += ["w"]*(width+2)+["\n"]
level[int(width*1.5+3.5)] = 'G'
#level[-(width+5)] = 'A'
level_str = ''.join(level)
return level_str
if __name__ == "__main__":
print ringworld(9)
from vgdl.core import VGDLParser
g = VGDLParser().parseGame(wrapmaze_game)
g.buildLevel(ringworld(19))
g.randomizeAvatar()
g.startGame()
VGDLParser.playGame(portalmaze_game, portalringworld(19))
示例15:
# 需要导入模块: from vgdl.core import VGDLParser [as 别名]
# 或者: from vgdl.core.VGDLParser import playGame [as 别名]
w w
w w
w w
w c c c w
wwwwwwwwwwwwwwwwwwwwwwww
"""
missilecommand_game = """
BasicGame
SpriteSet
city > Immovable color=GREEN
incoming > Chaser stype=city color=ORANGE speed=0.1
explosion > Flicker limit=5
avatar > ShootAvatar stype=explosion
LevelMapping
c > city
m > incoming
InteractionSet
movable wall > stepBack
incoming city > killSprite
city incoming > killSprite
incoming explosion > killSprite
TerminationSet
SpriteCounter stype=city win=False
SpriteCounter stype=incoming win=True
"""
if __name__ == "__main__":
from vgdl.core import VGDLParser
VGDLParser.playGame(missilecommand_game, missilecommand_level)