-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop support for reading RLGym types directly
- Loading branch information
Showing
10 changed files
with
340 additions
and
757 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
## rlviser-py | ||
|
||
Python implementation that manages a UDP connection to RLViser, it launches the [RLViser binary](https://github.com/VirxEC/rlviser) from the current working directory upon first calling any render function. | ||
|
||
Currently able to visualize RLGym GameState objects, but requires the boost pad locations to be sent first. | ||
Python implementation that manages a UDP connection to RLViser, it launches the [RLViser binary](https://github.com/VirxEC/rlviser) from the current working directory upon first calling any render function. | ||
|
||
The backbone of RLGym's `env.render()` functionality. | ||
|
||
### Example usage | ||
|
||
```python | ||
import time | ||
|
||
import rlviser_py as vis | ||
import RocketSim as rs | ||
|
||
# Create example arena | ||
arena = rs.Arena(rs.GameMode.SOCCAR) | ||
|
||
# Set boost pad locations | ||
vis.set_boost_pad_locations([pad.get_pos().as_tuple() for pad in arena.get_boost_pads()]) | ||
|
||
# Setup example arena | ||
car = arena.add_car(rs.Team.BLUE) | ||
car.set_state(rs.CarState(pos=rs.Vec(z=17), vel=rs.Vec(x=50), boost=100)) | ||
arena.ball.set_state(rs.BallState(pos=rs.Vec(y=400, z=100), ang_vel=rs.Vec(x=5))) | ||
car.set_controls(rs.CarControls(throttle=1, steer=1, boost=True)) | ||
|
||
# Run for 3 seconds | ||
TIME = 3 | ||
|
||
steps = 0 | ||
starttime = 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) | ||
|
||
# sleep to simulate running real time (it will run a LOT after otherwise) | ||
time.sleep(max(0, starttime + steps / arena.tick_rate - time.time())) | ||
steps += 1 | ||
|
||
# Tell RLViser to exit | ||
print("Exiting...") | ||
vis.quit() | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.