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

Uploaded Source

Built Distributions

rlviser_py-0.6.9-cp37-abi3-win_amd64.whl (153.4 kB view details)

Uploaded CPython 3.7+ Windows x86-64

rlviser_py-0.6.9-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (225.1 kB view details)

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

rlviser_py-0.6.9-cp37-abi3-macosx_10_12_x86_64.whl (201.2 kB view details)

Uploaded CPython 3.7+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rlviser_py-0.6.9.tar.gz
Algorithm Hash digest
SHA256 7679198d2181afef95d1a3c945ecf1fa489f05fe3d3ff1d2ec22f494724501ea
MD5 e3dac749deb3af718069dc88321f5e8c
BLAKE2b-256 4e582fb82c73b60f0617d2aef17b910c51ed77b75a141bd0e40a9cd250060626

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rlviser_py-0.6.9-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5204ab11e6c7f58e7dd48ee3528d2afbf773507e11aaa77cb24c4ce9f5e9ce61
MD5 49ab34867069d6302e05a526b00b3713
BLAKE2b-256 045ed5b2d0fbc3c21236c46f0aac8d33dde8c7268f9e763b7a0580712a2492e5

See more details on using hashes here.

File details

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

File metadata

File hashes

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

See more details on using hashes here.

File details

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

File metadata

File hashes

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

See more details on using hashes here.

Supported by

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