Skip to content
Snippets Groups Projects
Commit 6c510391 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Test inputting movement action

parent d3381997
No related branches found
No related tags found
1 merge request!2Resolve "2D movement continuous"
Pipeline #41285 failed
......@@ -4,6 +4,7 @@ from pathlib import Path
import numpy as np
from overcooked_simulator.counters import Counter
from overcooked_simulator.overcooked_environment import Action
from overcooked_simulator.player import Player
from overcooked_simulator.simulation_runner import Simulator
......@@ -38,7 +39,7 @@ def test_simulator_frequency():
self.c += 1
frequency = 2000
running_time_seconds = 4
running_time_seconds = 3
sim = Simulator(Path("../overcooked_simulator/layouts/basic.layout"), frequency)
sim.env = TestEnv() # Overwrite environment with a simple counting env
......@@ -54,8 +55,27 @@ def test_simulator_frequency():
assert lower < sim.env.c < upper, "Timing error in the environment at 1000hz"
def test_movement():
sim = Simulator(Path("../overcooked_simulator/layouts/empty.layout"), 200)
player_name = "p1"
start_pos = np.array([50, 50])
player1 = Player(player_name, start_pos)
sim.register_player(player1)
move_direction = np.array([1, 0])
move_action = Action(player_name, "movement", move_direction)
do_moves_number = 6
for i in range(do_moves_number):
sim.enter_action(move_action)
expected = start_pos + do_moves_number * (move_direction * player1.move_dist)
assert (
np.linalg.norm(expected - sim.env.players[player_name].pos) == 0
), "Should be here?"
def test_collision_detection():
sim = Simulator(Path("../overcooked_simulator/layouts/empty.layout.layout"), 200)
sim = Simulator(Path("../overcooked_simulator/layouts/empty.layout"), 200)
counter_pos = np.array([50, 100])
counter = Counter(counter_pos)
sim.env.counters = [counter]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment