From dad82050f82706ab3773dbf528a904968d38d385 Mon Sep 17 00:00:00 2001 From: Adrian Orenstein Date: Sun, 25 Aug 2024 20:49:27 -0600 Subject: [PATCH] if box contains nothing, do nothing --- minigrid/core/world_object.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/minigrid/core/world_object.py b/minigrid/core/world_object.py index a1fe01911..6e97943b7 100644 --- a/minigrid/core/world_object.py +++ b/minigrid/core/world_object.py @@ -288,6 +288,10 @@ def render(self, img): fill_coords(img, point_in_rect(0.16, 0.84, 0.47, 0.53), c) def toggle(self, env, pos): + # if the box is empty, do nothing + if self.contains is None: + return False + # Replace the box by its contents env.grid.set(pos[0], pos[1], self.contains) return True