Coder Social home page Coder Social logo

rocketsim's Introduction

image

A C++ library for simulating Rocket League games at maximum efficiency

RocketSim is a complete simulation of Rocket League's gameplay logic and physics that is completely standalone. RocketSim supports the game modes: Soccar, Hoops, Heatseeker, and Snowday.

Speed

RocketSim is designed to run extremely fast, even when complex collisions and suspension calculations are happening every tick. On an average PC running a single thread of RocketSim with two cars, RocketSim can simulate around 20 minutes of game time every second. This means that with 12 threads running RocketSim, you can simulate around 10 days of game time every minute!

Accuracy

RocketSim is not a perfectly accurate replication of Rocket League, but is close enough for most applications (such as training ML bots). Perceivable differences between the simulation and the real game usually take at least a second to accumulate from an initial state. This means RocketSim is accurate enough to:

  • Train machine learning bots
  • Simulate different shots on the ball at different angles to find the best input combination
  • Simulate air control to find the optimal orientation input
  • Simulate ground and floor pinches

However, RocketSim is NOT accurate enough to:

  • Accurately re-create entire games from inputs alone
  • Perfectly simulate long sequences of jumps and landings

Installation

Documentation

Documentation is available at: https://zealanl.github.io/RocketSimDocs/

Bindings

If you don't want to work in C++, here are some (unofficial) bindings written in other languages:

Official Python bindings are currently in the works.

Performance Details

RocketSim already heavily outperforms the speed of Rocket League's physics tick step without optimization.

Version performance comparison:

OS: Windows 10 (Process Priority = Normal)
CPU: Intel i5-11400 @ 2.60GHz
Ram Speed: 3200MZ
Compiler: MSVC 14.16
=================================
Arena: Default (Soccar)
Cars: 2 on each team (2v2)
Inputs: Randomly pre-generated, changed every 2-60 ticks for each car
=================================
Single-thread performance (calculated using average CPU cycles per tick on the RocketSim thread) (1M ticks simulated):
v1.0.0 = 30,334tps
v1.1.0 = 48,191tps
v1.2.0 = 50,763tps
v2.0.0 = ~50,000tps
v2.1.0 = 114,481tps

Issues & PRs

Feel free to make issues and pull requests if you encounter any issues!

You can also contact me on Discord if you have questions: Zealan#5987

Legal Notice

RocketSim was written to replicate Rocket League's game logic, but does not actually contain any code from the game. To Epic Games/Psyonix: If any of you guys have an issue with this, let me know on Discord and we can resolve it.

rocketsim's People

Contributors

ashkitten avatar benjamincburns avatar uservar avatar virxec avatar zealanl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rocketsim's Issues

trash

this is worse than some random ball prediction taken from cheats.

imagine training a bot for weeks on this shit only to put it in real rl and have it perform like plat

NaN car velocity

In this very contrived example (basically just a trace from an attempted training run) we observe that the car velocity is sometimes NaN.

I suppose this could be an issue in the python bindings, but it seems more likely a problem with the underlying engine, hence why I'm reporting it here.

Repro:

from rocketsim import Vec3, Angle
from rocketsim.sim import Arena, CarConfig, GameMode, Team, Car, CarControls, Ball

arena = Arena(GameMode.Soccar)
agent_id = arena.add_car(Team.Blue, CarConfig.Octane)


ball = arena.get_ball()

ball.pos = Vec3(0, 0, 5000)
ball.angvel = Vec3(0, 0, 0)
ball.vel = Vec3(0, 0, 0)

arena.ball = ball

agent = arena.get_car(agent_id)

# x = +- 3000
# y = +- 3000
agent.pos = Vec3(2040.60498046875, -2534.492919921875, 17.0)
agent.angles = Angle(-0.0, 0, 0)
agent.angvel = Vec3(0, 0, 0)
agent.boost = 100

control_dicts = [
    { "throttle": 0.0,  "steer": 0.5,  "pitch": 0.5,  "yaw": 0.5, "roll": 1.0, "jump": False, "boost": False, "handbrake": False },
    { "throttle": -1.0, "steer": 1.0,  "pitch": 1.0,  "yaw": 0.0, "roll": 0.0, "jump": False, "boost": False, "handbrake": True },
    { "throttle": 0.0,  "steer": 0.0,  "pitch": 0.0,  "yaw": 0.75, "roll": 1.0, "jump": True, "boost": False, "handbrake": True },
    { "throttle": 0.0,  "steer": 0.0,  "pitch": 0.0,  "yaw": 0.75, "roll": 0.0, "jump": False, "boost": False, "handbrake": False },
    { "throttle": 1.0,  "steer": -0.5, "pitch": -0.5, "yaw": 0.0, "roll": 0.0, "jump": False, "boost": True, "handbrake": False },
    { "throttle": 0.0,  "steer": 0.5,  "pitch": 0.5,  "yaw": -0.5, "roll": 0.0, "jump": False, "boost": False, "handbrake": False },
    { "throttle": -1.0, "steer": 1.0,  "pitch": 1.0,  "yaw": 0.0, "roll": 0.0, "jump": False, "boost": False, "handbrake": True },
    { "throttle": 0.0,  "steer": 0.0,  "pitch": 0.0,  "yaw": 1.0, "roll": -1.0, "jump": True, "boost": False, "handbrake": True }
]

def control(**kwargs):
    controls = CarControls(**kwargs)
    arena.set_car_controls(agent_id, controls)
    arena.step(8)
    car_vel = arena.get_car(agent_id).get_vel()
    print(f"Car vel: {car_vel}")

[ control(**control_dict) for control_dict in control_dicts ]

Output (notice final line has NaN values for x and y:

Car vel: Vec3 { x: -0.07, y: 0.03, z: 137.92 }
Car vel: Vec3 { x: -79.549995, y: -18.42, z: 72.88 }
Car vel: Vec3 { x: -92.6919, y: -13.390303, z: 398.83078 }
Car vel: Vec3 { x: -92.68999, y: -13.389998, z: 355.47 }
Car vel: Vec3 { x: -88.259995, y: -13.59, z: 312.18 }
Car vel: Vec3 { x: -88.259995, y: -13.59, z: 268.82 }
Car vel: Vec3 { x: -92.68999, y: -13.389998, z: 225.48997 }
Car vel: Vec3 { x: NaN, y: NaN, z: 220.06998 }

Small improvement to flip timer

This section

if (_internalState.hasFlipped) {
// Replicated from https://github.com/samuelpmish/RLUtilities/blob/develop/src/mechanics/dodge.cc
_internalState.flipTime += tickTime;
if (_internalState.flipTime <= FLIP_TORQUE_TIME) {

Could be changed to

if (_internalState.isFlipping) { 

So the timer stops counting after the flip is done

Small bug in Car AirControl pitch lock

The check in

if (_internalState.hasFlipped && _internalState.flipTime < FLIP_PITCHLOCK_TIME)

should be updated to

if (_internalState.isFlipping && _internalState.flipTime < FLIP_PITCHLOCK_TIME)

Otherwise the pitchlock remains active for FLIP_PITCHLOCK_TIME even if isFlipping was set to false during SetState

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.