Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block2D rendering failing with IndexError. #218

Closed
tekier opened this issue Jul 30, 2022 · 2 comments
Closed

Block2D rendering failing with IndexError. #218

tekier opened this issue Jul 30, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@tekier
Copy link

tekier commented Jul 30, 2022

I am currently trying to create an environment where a team of agents (jellies) compete with enemy units (gnomes) to win a shootout game. The gnomes are part of the environment and make use of A* and proximity triggers to fire on the jellies.

So far, I have been rendering the environment only using gd.ObserverType.ISOMETRIC. I tried to switch to gd.ObserverType.BLOCK_2D by specifying the following sections in the GDY file.

# Specifying this block for each object under the Observers key.
Block2D:
   -Shape: e.g. circle
     Color: [ x, y, z ]
     Scale: 1.0

# Specifying in the Environment section also under Observers
Block2D:
   TileSize: 30

When I run the program though, what I get is a couple of time steps rendering and then the following error:

Traceback (most recent call last):
  File "/Users/tekier/uni/diss/smac_lite/aliens/aliens.py", line 31, in <module>
    obs, reward, done, info = env.step(env.action_space.sample())
  File "/opt/anaconda3/envs/smac_lite/lib/python3.8/site-packages/gym/wrappers/order_enforcing.py", line 37, in step
    return self.env.step(action)
  File "/opt/anaconda3/envs/smac_lite/lib/python3.8/site-packages/gym/wrappers/step_api_compatibility.py", line 52, in step
    step_returns = self.env.step(action)
  File "/opt/anaconda3/envs/smac_lite/lib/python3.8/site-packages/griddly/GymWrapper.py", line 363, in step
    self._player_last_observation[p] = self._get_observation(self._players[p].observe(),
IndexError: map::at:  key not found

Hopefully, this is case of me just missing something from the GDY file, but I've had a look at some examples and it seems like I've got everything I need.

To Recreate
aliens.zip

  1. Download and unzip the attached folder.
  2. Run aliens.py

My environment:
MacOS Monterey 12.2
Python 3.8.13
Griddly version 1.4.3

@Bam4d
Copy link
Owner

Bam4d commented Jul 31, 2022

So this is something thats handled poorly in Griddly.

when you have something set up like this:

Isometric:
        - Image: oryx_iso_dungeon/fire-pink-up.png
          Scale: 0.5
        - Image: oryx_iso_dungeon/fire-pink-right.png
          Scale: 0.5
        - Image: oryx_iso_dungeon/fire-pink-down.png
          Scale: 0.5
        - Image: oryx_iso_dungeon/fire-pink-left.png
          Scale: 0.5
      Block2D:
        - Shape: circle
          Color: [ 0.8, 0, 0.1 ]
          Scale: 0.2

And you are using setTile commands... if there is only one tile for the block observer, it's basically crashing because its looking for the nth tile (which is set in the isometric observer but not the block observer)

A quick workaround would be to add 4 block shapes (that are the same).

In Griddly this should almost certainly throw a warning or an error (and just use the single tile that exists)

@Bam4d Bam4d self-assigned this Jul 31, 2022
@Bam4d Bam4d added the bug Something isn't working label Jul 31, 2022
@tekier
Copy link
Author

tekier commented Aug 1, 2022

Workaround seems to work fine.

@tekier tekier closed this as completed Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants