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.14.tar.gz (23.7 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.14-cp37-abi3-win_amd64.whl (202.8 kB view details)

Uploaded CPython 3.7+Windows x86-64

rlviser_py-0.6.14-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (285.7 kB view details)

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

rlviser_py-0.6.14-cp37-abi3-macosx_11_0_arm64.whl (250.0 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for rlviser_py-0.6.14.tar.gz
Algorithm Hash digest
SHA256 555ac09f8ce8a36e42104e1899b01c6efaa3988b9c30f2d69ad2cecccb468960
MD5 514f0d61de313f964610b43d778bf233
BLAKE2b-256 1b98393a9d5c33749c50105bfa8ec7f16559d674c9dd2d8a3ac3d165e9020995

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rlviser_py-0.6.14-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9fd2e5e61df26df3ec5c6d0d4997276dcdd27d259a7a433d0d78ca17744ff167
MD5 5a6f8ccdaff01d0b4f4e77e260ce015e
BLAKE2b-256 851915c46bb0824c1d1d193b69209a3e5ec7348408aeae864fabd4d0e87311f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rlviser_py-0.6.14-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16713fb38aeda60475d86ec014bfcad4c6fc50bcf3e49e4f553ef3debcd77cb6
MD5 c9f89cccdae9bb3506be1af898d8a558
BLAKE2b-256 342b601a39cff6ad707645f7fb61752228af057c5a93017f16f80488bef13461

See more details on using hashes here.

File details

Details for the file rlviser_py-0.6.14-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlviser_py-0.6.14-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e8889b0620e8509cf953088bd8cb183647eef7c1f1d733d2482db87275468c3
MD5 ef3ec1def77786df1172012f53fad97d
BLAKE2b-256 c3b83b7a10572a3ed43304189c13b7bdf443863335ac7cc150f2dafe14c728e5

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