Skip to main content

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


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.13.tar.gz (15.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rlviser_py-0.6.13-cp37-abi3-win_amd64.whl (160.5 kB view details)

Uploaded CPython 3.7+Windows x86-64

rlviser_py-0.6.13-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (241.5 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

rlviser_py-0.6.13-cp37-abi3-macosx_10_12_x86_64.whl (216.8 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file rlviser_py-0.6.13.tar.gz.

File metadata

  • Download URL: rlviser_py-0.6.13.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for rlviser_py-0.6.13.tar.gz
Algorithm Hash digest
SHA256 9cc4746379956bbc11511a3d3b82d4ead79318dc58bf4078287ccd9a5c11529d
MD5 a22261d5a10e2b57764b3c56f2a3455e
BLAKE2b-256 41854363579f07a1565013086e2e124f7aa50db5ed6a35c63419d9d7a15aafa1

See more details on using hashes here.

File details

Details for the file rlviser_py-0.6.13-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for rlviser_py-0.6.13-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ea7ad7f5309a97c877dce76e8ca491d7a8d6c77dbe2eb127c72f86c968a34819
MD5 e3b75d111bbd0444c5e73c422451c976
BLAKE2b-256 2aa2b1d71e8b8a68f87d5e5dc269b4ce1d8fd82c822f78b9c53435686d1e8a98

See more details on using hashes here.

File details

Details for the file rlviser_py-0.6.13-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlviser_py-0.6.13-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88e283d8683a7b5d40daaa412d95423bf70ff569356b6e1199aa80af375e9c8e
MD5 01660dcc05d00f1b02035592f0ef70e0
BLAKE2b-256 47e20a3182d8ab5d5d2f8f12ab62242e697f41249013e9620141bb972a102d88

See more details on using hashes here.

File details

Details for the file rlviser_py-0.6.13-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rlviser_py-0.6.13-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e3374a7002f39e6caf47d271fb49660b1bd2d9429b9067bad5beaf1c3bb8be2d
MD5 b7db4865f74a87f9aa7a89314e410e04
BLAKE2b-256 606b4009a70e188495d6e190bb8310621823fe3f670e106afe21691079148bcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page