Python implementation that manages a UDP connection to RLViser
Project description
rlviser-py
Python implementation that manages a UDP connection to RLViser, it launches the RLViser binary from the current working directory upon first calling any render function.
The backbone of RLGym's env.render()
functionality.
Example usage
import time
import rlviser_py as vis
import RocketSim as rs
game_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 = 3
steps = 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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rlviser_py-0.6.9.tar.gz
(13.6 kB
view hashes)
Built Distributions
Close
Hashes for rlviser_py-0.6.9-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5204ab11e6c7f58e7dd48ee3528d2afbf773507e11aaa77cb24c4ce9f5e9ce61 |
|
MD5 | 49ab34867069d6302e05a526b00b3713 |
|
BLAKE2b-256 | 045ed5b2d0fbc3c21236c46f0aac8d33dde8c7268f9e763b7a0580712a2492e5 |
Close
Hashes for rlviser_py-0.6.9-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40327ec20548349ffbc31e904ea67b38b2355e2b92fcd487baff2c2d7776d5db |
|
MD5 | edbf6dc4b3ce26d673e2ad45ee472ee5 |
|
BLAKE2b-256 | d77b25ea113113f408a084a1e27192a062d3761fb359430e4741277f336ff0e1 |
Close
Hashes for rlviser_py-0.6.9-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d38d340c80e5a3057a6cc2b09743350d5554ea1f48ecdd6aa604ad47be0c2e53 |
|
MD5 | d46d5046399713a3c8ddaf2780ecb317 |
|
BLAKE2b-256 | dfbcf4a7cb1667513183d8410b337fb72b1246ebf9fa1dc06d5be889aa7869bb |