Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed Oct 31, 2023
1 parent c48214c commit ff60b4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import time
import rlviser_py as vis
import RocketSim as rs

game_mode = rs.GameMode.SOCCAR

# Create example arena
arena = rs.Arena(rs.GameMode.SOCCAR)
arena = rs.Arena(game_mode)

# Set boost pad locations
vis.set_boost_pad_locations([pad.get_pos().as_tuple() for pad in arena.get_boost_pads()])
Expand All @@ -28,17 +30,22 @@ car.set_controls(rs.CarControls(throttle=1, steer=1, boost=True))
TIME = 3

steps = 0
starttime = time.time()
start_time = time.time()
for i in range(round(TIME * arena.tick_rate)):
arena.step(1)

# Render the current game state
pad_states = [pad.get_state().is_active for pad in arena.get_boost_pads()]
car_data = [(car.id, car.team, car.get_config(), car.get_state()) for car in arena.get_cars()]
vis.render(steps, arena.tick_rate, pad_states, arena.ball.get_state(), car_data)
ball = arena.ball.get_state()
car_data = [
(car.id, car.team, car.get_config(), car.get_state())
for car in arena.get_cars()
]

vis.render(steps, arena.tick_rate, game_mode, pad_states, ball, car_data)

# sleep to simulate running real time (it will run a LOT after otherwise)
time.sleep(max(0, starttime + steps / arena.tick_rate - time.time()))
time.sleep(max(0, start_time + steps / arena.tick_rate - time.time()))
steps += 1

# Tell RLViser to exit
Expand Down
4 changes: 2 additions & 2 deletions pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TIME = 3

steps = 0
starttime = time.time()
start_time = time.time()
for i in range(round(TIME * arena.tick_rate)):
arena.step(1)

Expand All @@ -36,7 +36,7 @@
vis.render(steps, arena.tick_rate, game_mode, pad_states, ball, car_data)

# sleep to simulate running real time (it will run a LOT after otherwise)
time.sleep(max(0, starttime + steps / arena.tick_rate - time.time()))
time.sleep(max(0, start_time + steps / arena.tick_rate - time.time()))
steps += 1

# Tell RLViser to exit
Expand Down

0 comments on commit ff60b4a

Please sign in to comment.