From c601ed13893b2220d9b1ee03982b128af6b10154 Mon Sep 17 00:00:00 2001
From: fheinrich <fheinrich@techfak.uni-bielefeld.de>
Date: Mon, 4 Dec 2023 14:55:13 +0100
Subject: [PATCH] Added pure player movement (without collisions)

---
 overcooked_simulator/counters.py               | 12 ++++++++++++
 overcooked_simulator/overcooked_environment.py | 13 ++-----------
 overcooked_simulator/player.py                 | 12 ++++++++----
 3 files changed, 22 insertions(+), 15 deletions(-)
 create mode 100644 overcooked_simulator/counters.py

diff --git a/overcooked_simulator/counters.py b/overcooked_simulator/counters.py
new file mode 100644
index 00000000..d37099f5
--- /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 71060740..bab89890 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 42f3d26f..b98df2d6 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,
-- 
GitLab