Permalink
Browse files

First commit

  • Loading branch information...
schaul committed Jun 18, 2012
1 parent d8d87a4 commit 7d60d3a53806ef4b925695a93cd746531ef2e702
View
@@ -1,4 +1,8 @@
py-vgdl
=======
-A video game description language (VGDL) built on top pf pygame.
+A high-level video game description language (VGDL) built on top of pygame.
+
+The aim is to decompose game descriptions into two parts: 1) a very high-level description, close to human language, to specify the dynamics, which builds on 2) an ontology of preprogrammed concepts for dynamics, interactions, control.
+Programmers extend the possibilities of (1) by writing modules in (2), and game designers can very quickly compose new games from those components without programming.
+
@@ -0,0 +1,62 @@
+'''
+VGDL example: a simplified variant of the classic space-invaders.
+
+@author: Tom Schaul
+'''
+
+# The game dynamics are specified as a paragraph of text
+
+aliens_game="""
+BasicGame
+ SpriteSet
+ base > Immovable color=WHITE
+ avatar > FlakAvatar shoot=sam
+ missile > Missile
+ sam > direction=UP color=BLUE singleton=True
+ bomb > direction=DOWN color=RED speedup=0.5
+ alien > Bomber stype=bomb prob=0.02 cooldown=4
+ portal > SpawnPoint stype=alien delay=16 total=20
+
+ LevelMapping
+ 0 > base
+ 1 > avatar
+ 2 > portal
+
+ TerminationSet
+ SpriteCounter stype=avatar limit=0 win=False
+ MultiSpriteCounter stype1=portal stype2=alien limit=0 win=True
+
+ InteractionSet
+ avatar EOS > stepBack
+ alien EOS > turnAround
+ missile EOS > killSprite
+ missile base > killSprite
+ base missile > killSprite
+ base alien > killSprite
+ avatar alien > killSprite
+ avatar bomb > killSprite
+ alien sam > killSprite
+"""
+
+# and the (initial) level as a block of characters too
+aliens_level = """
+wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
+w w
+w2 w
+w000 w
+w000 w
+w w
+w w
+w w
+w w
+w 000 000000 000 w
+w 00000 00000000 00000 w
+w 0 0 00 00 00000 w
+w 1 w
+wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
+"""
+
+if __name__ == "__main__":
+ from core import VGDLParser
+ # parse, run and play.
+ VGDLParser.playGame(aliens_game, aliens_level)
@@ -0,0 +1,53 @@
+'''
+VGDL example: a simple chasing butterflies game.
+
+If a butterfly hits a cocooned one, if frees it.
+If they all are freed, you lose.
+
+@author: Tom Schaul
+'''
+
+
+chase_game = """
+BasicGame
+ SpriteSet
+ wall > Immovable
+ cocoon > Immovable color=BLUE
+ animal > physicstype=GridPhysics
+ avatar > MovingAvatar speedup=1.5
+ butterfly > RandomNPC
+
+ TerminationSet
+ SpriteCounter stype=butterfly win=True
+ SpriteCounter stype=cocoon win=False
+
+ InteractionSet
+ butterfly avatar > killSprite
+ butterfly cocoon > cloneSprite
+ cocoon butterfly > killSprite
+ animal wall > stepBack
+
+ LevelMapping
+ w > wall
+ 1 > avatar
+ 2 > butterfly
+ 3 > cocoon
+"""
+
+chase_level = """
+wwwwwwwwwwwwwwwwwwwwwwwwwwww
+w 2 2 w 3 3 3 3w333w
+w 2 w333w
+w 2 3 1 w333w
+wwwwwwwwwwww 33w
+w3 w ww
+w3 2 w
+w3 wwwww 2 3w
+wwwww w w
+w 3 3 3 3 3 w3 3w
+wwwwwwwwwwwwwwwwwwwwwwwwwwww
+"""
+
+if __name__ == "__main__":
+ from core import VGDLParser
+ VGDLParser.playGame(chase_game, chase_level)
@@ -0,0 +1,61 @@
+'''
+VGDL example: a simple dodge-the-bullets game
+
+@author: Tom Schaul
+'''
+
+bullet_level = """
+wwwwwwwwwwwwwwwwwww
+w1 w < - 2w
+w w- w
+w ww w
+w < w ^ w w
+w ^ w V V ww
+w - v w
+ww < www w
+w w
+www v www
+wwwwwwwwwwwwwwwwwww
+"""
+
+bullet_game = """
+BasicGame
+ SpriteSet
+ bullet > Missile
+ slowbullet > speedup=0.1 color=ORANGE
+ upslow > direction=UP
+ downslow > direction=DOWN
+ leftslow > direction=LEFT
+ rightslow > direction=RIGHT
+ fastbullet > speedup=0.2 color=RED
+ rightfast > direction=RIGHT
+ downfast > direction=DOWN
+ wall > Immovable
+ goal > Immovable color=GREEN
+ avatar > MovingAvatar
+
+ InteractionSet
+ goal avatar > killSprite
+ avatar bullet > killSprite
+ avatar wall > stepBack
+ bullet EOS > wrapAround
+
+ TerminationSet
+ SpriteCounter stype=goal limit=0 win=True
+ SpriteCounter stype=avatar limit=0 win=False
+
+ LevelMapping
+ w > wall
+ ^ > upslow
+ < > leftslow
+ v > downslow
+ - > rightslow
+ = > rightfast
+ V > downfast
+ 1 > avatar
+ 2 > goal
+"""
+
+if __name__ == "__main__":
+ from core import VGDLParser
+ VGDLParser.playGame(bullet_game, bullet_level)
@@ -0,0 +1,68 @@
+'''
+VGDL example: a simplified variant of the classic frogger game.
+
+Logs spawn randomly, but trucks wrap around the screen and come back.
+
+@author: Tom Schaul
+'''
+
+frog_level = """
+wwwwwwwwwwwwwwwwwwwwwwwwwwww
+w w2w w
+w00==000000===0000=====000=4
+w0000====0000000000====00034
+w00===000===000====0000===04
+www ww www www wwwww
+w ---- --- - ---- w
+w- xxx xxx xx w
+w - --- - ---- -- w
+w 1 w
+wwwwwwwwwwwwwwwwwwwwwwwwwwww
+"""
+
+
+frog_game = """
+BasicGame
+ SpriteSet
+ forest > SpawnPoint stype=log prob=0.4 delay=10
+ structure > Immovable
+ water > color=BLUE
+ goal > color=GREEN
+ log > Missile direction=LEFT speedup=0.1 color=BROWN
+ truck > Missile direction=RIGHT
+ fasttruck > speedup=0.2 color=ORANGE
+ slowtruck > speedup=0.1 color=RED
+ avatar > Frog
+ # defining 'wall' last, makes the walls show on top of all other sprites
+ 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
+ w > wall
+ 0 > water
+ 1 > avatar
+ 2 > goal
+ 3 > forest water # note how a single character can spawn multiple sprites
+ 4 > forest wall log
+ - > slowtruck
+ x > fasttruck
+ = > log water
+
+"""
+
+if __name__ == "__main__":
+ from core import VGDLParser
+ VGDLParser.playGame(frog_game, frog_level)
@@ -0,0 +1,69 @@
+'''
+VGDL example: a simple teleport-and-avoid-fire game.
+
+@author: Tom Schaul
+'''
+
+portal_level = """
+wwwwwwwwwwwwwwwwwww
+w1 w v < wO 2w
+wo iw wx w
+wwwww o wwwwww
+w w r w ow
+w < wwwwwww ww
+w x < w
+wwwww www w
+wr i w
+wwwIw v x www
+wwwwwwwwwwwwwwwwwww
+"""
+
+portal_game = """
+BasicGame
+ SpriteSet
+ bullet > color=ORANGE
+ sitting > Immovable
+ random > RandomNPC speedup=0.25
+ straight > Missile speedup=0.5
+ vertical > direction=UP
+ horizontal > direction=LEFT
+ structure > Immovable
+ wall >
+ goal > color=GREEN
+ portalentry > Portal color=BLUE
+ entry1 > stype=exit1
+ entry2 > stype=exit2
+ portalexit > color=BROWN
+ exit1 >
+ exit2 >
+ avatar > MovingAvatar
+
+ InteractionSet
+ goal avatar > killSprite
+ avatar bullet > killSprite
+ avatar wall > stepBack
+ straight wall > changeDirection
+ avatar portalentry > teleportToExit
+
+ TerminationSet
+ SpriteCounter stype=goal limit=0 win=True
+ SpriteCounter stype=avatar limit=0 win=False
+
+ LevelMapping
+ w > wall
+ < > horizontal
+ v > vertical
+ x > sitting
+ r > random
+ 1 > avatar
+ 2 > goal
+ i > entry1
+ I > entry2
+ o > exit1
+ O > exit2
+
+"""
+
+if __name__ == "__main__":
+ from core import VGDLParser
+ VGDLParser.playGame(portal_game, portal_level)
@@ -0,0 +1,51 @@
+'''
+VGDL example: a simplified Sokoban variant: push the boxes into the holes
+
+@author: Tom Schaul
+'''
+
+box_level = """
+wwwwwwwwwwwww
+w w w
+w 2 w
+w 1 2 w 0ww
+www w2 wwwww
+w w 0 w
+w 2 ww
+w ww
+wwwwwwwwwwwww
+"""
+
+
+push_game = """
+BasicGame frame_rate=30
+ SpriteSet
+ wall > Immovable
+ hole > Immovable color=GREEN
+ movable >
+ avatar > MovingAvatar cooldown=10
+ box > Passive
+
+ LevelMapping
+ w > wall
+ 0 > hole
+ 1 > avatar
+ 2 > box
+
+ InteractionSet
+ avatar wall > stepBack
+ box avatar > bounceForward
+ box wall > undoAll
+ box box > undoAll
+ movable hole> killSprite
+
+ TerminationSet
+ Timeout limit=10000
+ SpriteCounter stype=box limit=0 win=True
+ SpriteCounter stype=avatar limit=0 win=False
+
+"""
+
+if __name__ == "__main__":
+ from core import VGDLParser
+ VGDLParser.playGame(push_game, box_level)
Oops, something went wrong.

0 comments on commit 7d60d3a

Please sign in to comment.