Labyrinth

Single-Player/GVGAI/labyrinth.yaml

Description

Its a maze, find your way out. Watch out for spikey things.

Levels

Code Example

The most basic way to create a Griddly Gym Environment. Defaults to level 0 and SPRITE_2D rendering.

import gym
import griddly

if __name__ == '__main__':

    env = gym.make('GDY-Labyrinth-v0')
    env.reset()

    # Replace with your own control algorithm!
    for s in range(1000):
        obs, reward, done, info = env.step(env.action_space.sample())
        env.render() # Renders the environment from the perspective of a single player

        env.render(observer='global') # Renders the entire environment

        if done:
            env.reset()

Objects

Tiles

Name ->

avatar

exit

trap

wall

Map Char ->

A

x

t

w

Block2D

../../_images/Labyrinth-tile-avatar-Block2D.png ../../_images/Labyrinth-tile-exit-Block2D.png ../../_images/Labyrinth-tile-trap-Block2D.png ../../_images/Labyrinth-tile-wall-Block2D.png

Sprite2D

../../_images/Labyrinth-tile-avatar-Sprite2D.png ../../_images/Labyrinth-tile-exit-Sprite2D.png ../../_images/Labyrinth-tile-trap-Sprite2D.png ../../_images/Labyrinth-tile-wall-Sprite2D.png

Vector

../../_images/Labyrinth-tile-avatar-Vector.png ../../_images/Labyrinth-tile-exit-Vector.png ../../_images/Labyrinth-tile-trap-Vector.png ../../_images/Labyrinth-tile-wall-Vector.png

Actions

move

Action Id

Mapping

1

Left

2

Up

3

Right

4

Down

YAML

Version: "0.1"
Environment:
  Name: Labyrinth
  Description: Its a maze, find your way out. Watch out for spikey things.
  Observers:
    Sprite2D:
      TileSize: 24
      BackgroundTile: gvgai/oryx/backBiege.png
  Player:
    AvatarObject: avatar
  Termination:
    Win:
      - eq: [exit:count, 0]
    Lose:
      - eq: [avatar:count, 0]
  Levels:
    - |
      w w w w w w w w w w w w w w w w
      w w . . . . . w w w . . . . x w
      w w . w w w . w w w . w w w w w
      w w . w . w . . . . . . . w t w
      w w . w . w w w w . w w w w . w
      w . . . . . . w w w w . . . . w
      w . w w w w . w w w w . w w w w
      w . . . . w . . . . . . . . . w
      w w w w w w . w w w w . w w . w
      w . . . . . . . . . . . . . . w
      w . w w w w . w w w . w w w . w
      w . w . w w . w w w . w w w w w
      w A w . . . . . t . . . . . . w
      w w w w w w w w w w w w w w w w
    - |
      w w w w w w w w w w w w w w w w
      w w w w w w w w w w w w w . . w
      w x t t t t w . . . . . w w . w
      w . . . . . . . w w w . . . . w
      w w w w w w w w w . w w w w . w
      w . . . w w w w w . w w w w . w
      w w w . . . . . . . . . w w . w
      w t w . w w w w w . w . . . . w
      w . w w w w w w w . w w w w . w
      w . w w w . . . . . w w w w . w
      w . w w w . w w w w w w w w . w
      w . w w w . w w w . w w w w w w
      w . . . . . . . . . . . . . A w
      w w w w w w w w w w w w w w w w
    - |
      w w w w w w w w w w w w w w w w
      w w w w w w w . x w w . . . t w
      w . . . . . . . w . w . w w w w
      w . w w . w w w w . w . . . . w
      w . w w . w w w . . w w w w . w
      w w w t . w w w . w w w . . . w
      w . . . . w w w . w w w . w w w
      w . w w w w w w . w w w . w w w
      w . t . . . . . . . . . . . . w
      w . w . w w w w . w w w . w w w
      w . w . . . . w . w w w . w w w
      w . w w w w . w . w w w . w w w
      w . . . . . . w A w w w . w w w
      w w w w w w w w w w w w w w w w
    - |
      w w w w w w w w w w w w w w w w
      w . . . . . . . . . . . . . . w
      w . w w w w w w w w w w w w . w
      w . w . . . . . . . . . . w . w
      w . w w w . w w w . w w . w . w
      w . w w w . w w w t w w . w . w
      w . w w w . w w w . w w . w . w
      w A . . . . . . . . . . . t x w
      w . w w w . w . w w w w . w w w
      w . w w w w w . w w w w . w w w
      w . . . . . . . w w w w . w w w
      w . w w w w w . w w w w . w w w
      w . . . . . . . . . . . . . t w
      w w w w w w w w w w w w w w w w
    - |
      w w w w w w w w w w w w w w w w
      w . . . . . . . . . . . . t A w
      w . w w w w w w w w w w . w . w
      w . . . . . . . . . . w . w . w
      w w w w w w w w w t . w . w . w
      w . . . . . . . . . . w . w . w
      w . w w w w w w w w w w . w . w
      w . w . . . w . . . w w . w . w
      w . w . w . . . w . . w . w . w
      w . w . w w w w w w w w . w . w
      w . w . . . . . . . . . . w . w
      w . w . t w w w w w w w . w . w
      w x w . . . . . . . . w . . . w
      w w w w w w w w w w w w w w w w

Actions:
  # Define the move action
  - Name: move
    Behaviours:
      # Avatar can move into empty space
      - Src:
          Object: avatar
          Commands:
            - mov: _dest
        Dst:
          Object: _empty

      # If Avatar hits a trap, remove it
      - Src:
          Object: avatar
          Commands:
            - remove: true
            - reward: -1
        Dst:
          Object: trap

      # If Avatar hits the exit, remove the exit
      - Src:
          Object: avatar
          Commands:
            - reward: 1
        Dst:
          Object: exit
          Commands:
            - remove: true

Objects:
  - Name: avatar
    MapCharacter: A
    Observers:
      Sprite2D:
        - Image: gvgai/newset/girl1.png
      Block2D:
        - Shape: triangle
          Color: [0.2, 0.8, 0.2]
          Scale: 0.6

  - Name: exit
    MapCharacter: x
    Observers:
      Sprite2D:
        - Image: gvgai/newset/exit2.png
      Block2D:
        - Shape: square
          Color: [0.2, 0.2, 0.8]
          Scale: 0.7

  - Name: trap
    MapCharacter: t
    Observers:
      Sprite2D:
        - Image: gvgai/oryx/spike2.png
      Block2D:
        - Shape: triangle
          Color: [1.0, 0.0, 0.0]
          Scale: 0.3

  - Name: wall
    MapCharacter: w
    Observers:
      Sprite2D:
        - TilingMode: WALL_16
          Image:
            - oryx/oryx_fantasy/wall8-0.png
            - oryx/oryx_fantasy/wall8-1.png
            - oryx/oryx_fantasy/wall8-2.png
            - oryx/oryx_fantasy/wall8-3.png
            - oryx/oryx_fantasy/wall8-4.png
            - oryx/oryx_fantasy/wall8-5.png
            - oryx/oryx_fantasy/wall8-6.png
            - oryx/oryx_fantasy/wall8-7.png
            - oryx/oryx_fantasy/wall8-8.png
            - oryx/oryx_fantasy/wall8-9.png
            - oryx/oryx_fantasy/wall8-10.png
            - oryx/oryx_fantasy/wall8-11.png
            - oryx/oryx_fantasy/wall8-12.png
            - oryx/oryx_fantasy/wall8-13.png
            - oryx/oryx_fantasy/wall8-14.png
            - oryx/oryx_fantasy/wall8-15.png
      Block2D:
        - Shape: square
          Color: [0.5, 0.5, 0.5]
          Scale: 0.9