Skip to content
Snippets Groups Projects

Resolve "More FOV"

Merged Fabian Heinrich requested to merge 89-more-fov into main
Files
3
@@ -239,8 +239,6 @@ class Environment:
) = self.parse_layout_file()
self.hook(LAYOUT_FILE_PARSED)
self.counter_positions = np.array([c.pos for c in self.counters])
self.world_borders = np.array(
[[-0.5, self.kitchen_width - 0.5], [-0.5, self.kitchen_height - 0.5]],
dtype=float,
@@ -250,6 +248,9 @@ class Environment:
"player_speed_units_per_seconds"
]
self.player_radius = self.environment_config["player_config"]["radius"]
self.player_interaction_range = self.environment_config["player_config"][
"interaction_range"
]
progress_counter_classes = list(
filter(
@@ -269,6 +270,8 @@ class Environment:
)
"""Counters that needs to be called in the step function via the `progress` method."""
self.counter_positions = np.array([c.pos for c in self.counters])
self.order_and_score.create_init_orders(self.env_time)
self.start_time = self.env_time
"""The relative env time when it started."""
@@ -290,6 +293,27 @@ class Environment:
env_start_time_worldtime=datetime.now(),
)
def overwrite_counters(self, counters):
self.counters = counters
self.counter_positions = np.array([c.pos for c in self.counters])
progress_counter_classes = list(
filter(
lambda cl: hasattr(cl, "progress"),
dict(
inspect.getmembers(
sys.modules["overcooked_simulator.counters"], inspect.isclass
)
).values(),
)
)
self.progressing_counters = list(
filter(
lambda c: c.__class__ in progress_counter_classes,
self.counters,
)
)
@property
def game_ended(self) -> bool:
"""Whether the game is over or not based on the calculated `Environment.env_time_end`"""
@@ -666,9 +690,21 @@ class Environment:
for idx, p in enumerate(self.players.values()):
if not (new_positions[idx] == player_positions[idx]).all():
p.move_abs(new_positions[idx])
p.pos = new_positions[idx]
p.perform_interact_stop()
p.turn(player_movement_vectors[idx])
facing_distances = np.linalg.norm(
p.facing_point - self.counter_positions, axis=1
)
closest_counter = self.counters[facing_distances.argmin()]
p.current_nearest_counter = (
closest_counter
if facing_distances.min() <= self.player_interaction_range
else None
)
def add_player(self, player_name: str, pos: npt.NDArray = None):
"""Add a player to the environment.
Loading