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.10.tar.gz (13.5 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.10-cp37-abi3-win_amd64.whl (155.8 kB view details)

Uploaded CPython 3.7+Windows x86-64

rlviser_py-0.6.10-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (231.3 kB view details)

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

rlviser_py-0.6.10-cp37-abi3-macosx_10_12_x86_64.whl (208.5 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rlviser_py-0.6.10.tar.gz
Algorithm Hash digest
SHA256 9a01e31f242de4ae5ac06fba767e4c7a8c3704640bdf567bd824867a6c80fc54
MD5 69ef96a27cfb2405d38796fdd0509103
BLAKE2b-256 0a55beb9683916b5543455b22eeb8417fd585063abf5a9bf58b9001eed63a01f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rlviser_py-0.6.10-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ac3f5a119e7128deb7cf20603e3bb3c8d44f502d2bfe251ce6e148babf9d39fb
MD5 ea65dbaf7519e840d8693eae0822611d
BLAKE2b-256 23070c2c70464556dec7ef0d84e0290d6c1128ea2787807b8b5a8926e8ce79ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rlviser_py-0.6.10-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca0d808749cfd67f95667de6fd133595e8c2da6e00bb6c64774098237ec6b9c9
MD5 900e52f82eabcb125c6f0e288c4b3692
BLAKE2b-256 c00c5380b0d9ae6a4fd1be7b37556289286e9be24d5acb86b359e7e85efa3e63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rlviser_py-0.6.10-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 94098447be381ab3aed4b7376f3983e2cb98494ba7e053bfe96b9194a08efe46
MD5 5807b9067aa56fccccc4b8807f5a43c7
BLAKE2b-256 3245daf3ede84e2f6205b98650c6b4551cc0b1a440b2e28863f20e7a3b238983

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