matomatical / jaxgmg

JAX-based environments and RL baselines for studying goal misgeneralisation.
MIT License
2 stars 0 forks source link

Possibility for generating invalid levels #7

Open matomatical opened 4 months ago

matomatical commented 4 months ago

In some rare[^1] cases, the level generators will create "invalid" levels, for which important assumptions underlying the environment implementation are violated. For example:

  1. In Cheese in the Corner, it's possible that the layout will place walls in the entire region where the cheese is allowed to spawn (for example, a block is placed at (1,1) and the corner_size parameter is set to 1). In this case, the cheese might spawn inside a wall, or perhaps along the boundary, I'm not sure, the point being that the code assumes this won't happen.
  2. In Keys and Chests when a large number of keys and/or chests is requested and it exceeds the number of free spaces. Then you can start having mouse/keys/chests spawning on walls and/or overlapping each other.

There are probably more examples. Resolving this issue will require finding all of them.

Once found, the generators should be improved such that it is no longer possible to generate these levels. For example, in (1), if the corner region is entirely occupied, wall could be removed to make room for the cheese. For (2), walls could be removed to make room for the chests and keys to spawn, and the level generator could have static assertions added that prevent the number of keys and chests (plus the mouse) from exceeding the maximum number of available cells.

Notes:

[^1]: Rare in this case means vanishingly unlikely for default configuration, however note that some of these issues are quite likely or can be ensured under some pathological configurations (e.g. setting block probabilities or #keys/#chests very high in the above examples).

matomatical commented 4 months ago

The baselines branch includes a fix for the first example in the Cheese in the Corner environment. There is still an issue with the spawning of the mouse in that environment. More generally there is still more work to do to systematically find more examples.