diff --git a/overcooked_simulator/counters.py b/overcooked_simulator/counters.py new file mode 100644 index 0000000000000000000000000000000000000000..d37099f5b144afa5a78fd7d75aaf51a6df9b04a8 --- /dev/null +++ b/overcooked_simulator/counters.py @@ -0,0 +1,12 @@ +import numpy as np + + +class Counter: + """Simple class for a counter at a specified position (center of counter). Can hold things on top. + """ + def __init__(self, pos: np.array): + self.pos = pos + self.occupied_by = None + + def __repr__(self): + return f"Counter(pos:{str(self.pos)},holds:{self.occupied_by})" \ No newline at end of file diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 71060740332ed8a2c041cfac8a6dd841c1edeb64..bab8989038a88a6d0a9f7682b2683a9360d32e65 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -5,17 +5,8 @@ if TYPE_CHECKING: from overcooked_simulator.player import Player from pathlib import Path import numpy as np - - -class Counter: - """Simple class for a counter at a specified position (center of counter). Can hold things on top. - """ - def __init__(self, pos: np.array): - self.pos = pos - self.occupied_by = None - - def __repr__(self): - return f"Counter(pos:{str(self.pos)},holds:{self.occupied_by})" +from scipy.spatial import distance_matrix +from counters import Counter class Action: diff --git a/overcooked_simulator/player.py b/overcooked_simulator/player.py index 42f3d26fff900cbbd059de18c68657da34fbe558..b98df2d6efa5b0e73fea9362304572bee1091a22 100644 --- a/overcooked_simulator/player.py +++ b/overcooked_simulator/player.py @@ -1,5 +1,5 @@ import numpy as np -from overcooked_simulator.overcooked_environment import Counter +from counters import Counter class Player: @@ -14,6 +14,7 @@ class Player: self.holding = None self.move_dist = 5 + self.interaction_range = 50 self.facing_direction = np.array([0, 1]) def move(self, movement: np.array): @@ -23,7 +24,9 @@ class Player: Args: movement: 2D-Vector of length 1 """ - pass + self.pos += movement + if np.linalg.norm(movement) != 0: + self.turn(movement) def move_abs(self, new_pos: np.array): """Overwrites the player location by the new_pos 2d-vector. Absolute movement. @@ -32,7 +35,7 @@ class Player: Args: new_pos: 2D-Vector of the new player position. """ - pass + self.pos = new_pos def turn(self, direction: np.array): """Turns the player in the given direction. Overwrites the facing_direction by a given 2d-vector. @@ -41,7 +44,8 @@ class Player: Args: direction: 2D-Vector of the direction for the player to face. """ - pass + if np.linalg.norm(direction) != 0: + self.facing_direction = direction / np.linalg.norm(direction) def pick_action(self, counter: Counter): """Performs the pickup-action with the counter. Handles the logic of what the player is currently holding,