diff --git a/overcooked_simulator/game_content/layouts/basic.layout b/overcooked_simulator/game_content/layouts/basic.layout index ccc4076303e985a8b60c9f2dd091f323b5d6e7a6..5f8ed4dea5f9bb748c460606813c913e481c1caf 100644 --- a/overcooked_simulator/game_content/layouts/basic.layout +++ b/overcooked_simulator/game_content/layouts/basic.layout @@ -5,5 +5,5 @@ W__________I #__A_____A_D C__________E C__________G -#__________# +#___________ #P#S+#X##S+# \ No newline at end of file diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 51eaef1a8aec0f89495b761f27cca6a5c87bf3fe..ba95189ddb0236c85635d9527b45cfb849138170 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -162,6 +162,9 @@ class Environment: self.free_positions, ) = self.parse_layout_file() + self.world_borders_x = [-0.5, self.kitchen_width - 0.5] + self.world_borders_y = [-0.5, self.kitchen_height - 0.5] + progress_counter_classes = list( filter( lambda cl: hasattr(cl, "progress"), @@ -315,14 +318,10 @@ class Environment: free_positions.append(np.array([current_x, current_y])) current_x += 1 - # if current_x > self.kitchen_width: - # self.kitchen_width = current_x current_y += 1 - # self.kitchen_width -= 0.5 - self.kitchen_width: float = len(lines[0]) - self.kitchen_height = len(lines) - + self.kitchen_width: float = len(lines[0]) + 2 + self.kitchen_height = len(lines) + 2 self.counter_factory.post_counter_setup(counters) return counters, designated_player_positions, free_positions @@ -565,9 +564,13 @@ class Environment: Returns: True if the player touches the world bounds, False if not. """ - collisions_lower = any((player.pos - (player.radius)) < 0) + collisions_lower = any( + (player.pos - (player.radius)) + < [self.world_borders_x[0], self.world_borders_y[0]] + ) collisions_upper = any( - (player.pos + (player.radius)) > [self.kitchen_width, self.kitchen_height] + (player.pos + (player.radius)) + > [self.world_borders_x[1], self.world_borders_y[1]] ) return collisions_lower or collisions_upper @@ -586,21 +589,21 @@ class Environment: counter.progress(passed_time=passed_time, now=self.env_time) self.order_and_score.progress(passed_time=passed_time, now=self.env_time) - # def get_state(self): - # """Get the current state of the game environment. The state here is accessible by the current python objects. - # - # Returns: Dict of lists of the current relevant game objects. - # - # """ - # return { - # "players": self.players, - # "counters": self.counters, - # "score": self.order_and_score.score, - # "orders": self.order_and_score.open_orders, - # "ended": self.game_ended, - # "env_time": self.env_time, - # "remaining_time": max(self.env_time_end - self.env_time, timedelta(0)), - # } + def get_state(self): + """Get the current state of the game environment. The state here is accessible by the current python objects. + + Returns: Dict of lists of the current relevant game objects. + + """ + return { + "players": self.players, + "counters": self.counters, + "score": self.order_and_score.score, + "orders": self.order_and_score.open_orders, + "ended": self.game_ended, + "env_time": self.env_time, + "remaining_time": max(self.env_time_end - self.env_time, timedelta(0)), + } def get_json_state(self, player_id: str = None): state = {