https://github.com/virxec/rlviser-py
Easy communication with RLViser from Python
https://github.com/virxec/rlviser-py
pyo3 python rlbot rlgym rust
Last synced: about 1 month ago
JSON representation
Easy communication with RLViser from Python
- Host: GitHub
- URL: https://github.com/virxec/rlviser-py
- Owner: VirxEC
- License: mit
- Created: 2023-06-05T15:18:43.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-08T15:46:00.000Z (11 months ago)
- Last Synced: 2025-04-12T03:38:52.111Z (about 1 month ago)
- Topics: pyo3, python, rlbot, rlgym, rust
- Language: Rust
- Homepage: https://pypi.org/project/rlviser-py/
- Size: 66.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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.
The backbone of RLGym's `env.render()` functionality.
### Example usage
```python
import timeimport rlviser_py as vis
import RocketSim as rsgame_mode = rs.GameMode.SOCCAR
# Create example arena
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()])# 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 = 3steps = 0
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()]
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, start_time + steps / arena.tick_rate - time.time()))
steps += 1# Tell RLViser to exit
print("Exiting...")
vis.quit()
```