Doggo

Single-Player/Mini-Grid/minigrid-doggo.yaml

Description

A port of the games provided in the https://github.com/maximecb/gym-minigrid Empty environment, but you’re a doggo fetching a stick.

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-Doggo-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 ->

wall

stick

doggo

Map Char ->

W

g

A

Block2D

../../_images/Doggo-tile-wall-Block2D.png ../../_images/Doggo-tile-stick-Block2D.png ../../_images/Doggo-tile-doggo-Block2D.png

Sprite2D

../../_images/Doggo-tile-wall-Sprite2D.png ../../_images/Doggo-tile-stick-Sprite2D.png ../../_images/Doggo-tile-doggo-Sprite2D.png

Vector

../../_images/Doggo-tile-wall-Vector.png ../../_images/Doggo-tile-stick-Vector.png ../../_images/Doggo-tile-doggo-Vector.png

Actions

move

Relative

The actions are calculated relative to the object being controlled.

Action Id

Mapping

1

Rotate left

2

Move forwards

3

Rotate right

YAML

Version: "0.1"
Environment:
  Name: Doggo
  Description: A port of the games provided in the https://github.com/maximecb/gym-minigrid Empty environment, but you're a doggo fetching a stick.
  Observers:
    Sprite2D:
      TileSize: 24
      BackgroundTile: oryx/oryx_fantasy/floor9-3.png
  Player:
    Observer:
      RotateWithAvatar: true
      TrackAvatar: true
      Height: 7
      Width: 7
      OffsetX: 0
      OffsetY: 3
    AvatarObject: doggo
  Termination:
    Win:
      - eq: [stick:count, 0] # If there are no boxes left
  Levels:
    - |
      W  W  W  W  W  W
      W  A  .  .  .  W
      W  .  .  .  .  W
      W  .  .  .  .  W
      W  .  .  .  g  W
      W  W  W  W  W  W
    - |
      W  W  W  W  W  W  W
      W  A  .  .  .  .  W
      W  .  .  .  .  .  W
      W  .  .  .  .  .  W
      W  .  .  .  .  .  W
      W  .  .  .  .  g  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  .  .  .  .  .  g  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  .  .  .  .  .  .  .  g  W
      W  W  W  W  W  W  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  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  g  W
      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
    InputMapping:
      Inputs:
        1:
          Description: Rotate left
          OrientationVector: [-1, 0]
        2:
          Description: Move forwards
          OrientationVector: [0, -1]
          VectorToDest: [0, -1]
        3:
          Description: Rotate right
          OrientationVector: [1, 0]
      Relative: true
    Behaviours:
      # Tell the agent to rotate if the doggo performs an action on itself
      - Src:
          Object: doggo
          Commands:
            - rot: _dir
        Dst:
          Object: doggo

      # The agent can move around freely in empty and always rotates the direction it is travelling
      - Src:
          Object: doggo
          Commands:
            - mov: _dest
        Dst:
          Object: _empty

      # If the doggo moves into a stick object, the stick is removed, triggering a win condition
      - Src:
          Object: doggo
          Commands:
            - reward: 1
        Dst:
          Object: stick
          Commands:
            - remove: true

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

  - Name: stick
    MapCharacter: g
    Observers:
      Sprite2D:
        - Image: oryx/oryx_fantasy/stick-0.png
      Block2D:
        - Shape: square
          Color: [0.0, 1.0, 0.0]
          Scale: 0.8

  - Name: doggo
    MapCharacter: A
    Observers:
      Sprite2D:
        - Image: oryx/oryx_fantasy/avatars/doggo1.png
      Block2D:
        - Shape: triangle
          Color: [1.0, 0.0, 0.0]
          Scale: 1.0