forked from VirxEC/rocketsim-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytest.py
46 lines (34 loc) · 1.22 KB
/
pytest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from time import time_ns
from rocketsim import Angle, Vec3
from rocketsim.sim import Arena, CarConfig, GameMode, Team, CarControls
if __name__ == "__main__":
arena = Arena(GameMode.Soccar)
print(f"Arena tick rate: {arena.get_tick_rate()}")
ball = arena.get_ball()
ball.pos = ball.get_pos().with_z(1500)
arena.ball = ball
print("Set ball state")
car_id = arena.add_car(Team.Blue, CarConfig.Octane)
print(f"ID of added car: {car_id}")
car = arena.get_car(car_id)
car.pos = Vec3(0, 0, 1050)
car.angles = Angle(0, 1.1, 0)
car.boost = 100
arena.set_car(car_id, car)
print("Set car state")
arena.set_car_controls(car_id, CarControls(boost=True))
print("Set car controls")
ticks = 7200
start_time = time_ns()
arena.step(ticks)
end_time = time_ns()
inactive_pads = 0
for i in range(arena.num_pads()):
pad = arena.get_pad_state(i)
if not pad.is_active:
inactive_pads += 1
pos = arena.get_pad_static(i).pos
print(f"Pad {i} is inactive at {pos}")
if inactive_pads == 0:
print("All pads are active")
print(f"Simulated {ticks / 120}s of game time in {(end_time - start_time) / 1e6}ms real time")