Skip to content

Commit

Permalink
Update example bots, improve python bindings & more (#37)
Browse files Browse the repository at this point in the history
* Add keyword arguments to python bindings

* Improve stub generation

* Bring back time_delta

* Update and simplify example bots

Resolves #36

* Remove o_dodge, q and rotator, make dodge_dir local
  • Loading branch information
Darxeal authored Jul 2, 2021
1 parent f5f375f commit 546c650
Show file tree
Hide file tree
Showing 130 changed files with 834 additions and 9,534 deletions.
5 changes: 0 additions & 5 deletions inc/simulation/car.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ class Car {
vec3 velocity;
vec3 angular_velocity;
mat3 orientation;
mat2 o_dodge;

vec4 q; // quaternion
vec3 rotator;

bool supersonic;
bool jumped;
Expand All @@ -116,7 +112,6 @@ class Car {
float boost_timer;
bool enable_jump_acceleration;

vec2 dodge_dir;
vec3 dodge_torque;

int frame;
Expand Down
2 changes: 2 additions & 0 deletions inc/simulation/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ struct Game {
float time;
float time_remaining;

float time_delta;

GameState state;

static vec3 gravity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import math

from rlbot.agents.base_agent import BaseAgent, SimpleControllerState
from rlbot.agents.human.controller_input import controller
from rlbot.utils.structures.game_data_struct import GameTickPacket

from rlutilities.simulation import Ball, Field, Game
from rlutilities.linear_algebra import vec3

class Agent(BaseAgent):

def __init__(self, name, team, index):
Game.set_mode("soccar")
self.game = Game(index, team)

def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
self.game.read_game_information(packet, self.get_rigid_body_tick(), self.get_field_info())

# make a copy of the ball's info that we can change
b = Ball(self.game.ball)

ball_predictions = []
for i in range(360):

# simulate the forces acting on the ball for 1 frame
b.step(1.0 / 120.0)

# and add a copy of new ball position to the list of predictions
ball_predictions.append(vec3(b.location))

self.renderer.begin_rendering()
red = self.renderer.create_color(255, 255, 30, 30)
self.renderer.draw_polyline_3d(ball_predictions, red)
self.renderer.end_rendering()

return controller.get_output()
from rlbot.agents.base_agent import BaseAgent, SimpleControllerState
from rlbot.agents.human.controller_input import controller
from rlbot.utils.structures.game_data_struct import GameTickPacket

from rlutilities.simulation import Ball, Field, Game
from rlutilities.linear_algebra import vec3


class Agent(BaseAgent):

def initialize_agent(self):
Game.set_mode("soccar")
self.game = Game()
self.game.read_field_info(self.get_field_info())

def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
self.game.read_packet(packet)

# make a copy of the ball's info that we can change
ball = Ball(self.game.ball)

ball_positions = []
for _ in range(360):

# simulate the forces acting on the ball for 1 frame
ball.step(1 / 120) # game physics run at 120 Hz

# and add a copy of new ball position to the list of predictions
ball_positions.append(vec3(ball.position))

# render the predicted path
self.renderer.draw_polyline_3d(ball_positions, self.renderer.yellow())

# to play around with the ball prediction, you can control this bot with your controller
return controller.get_output()
29 changes: 0 additions & 29 deletions python/examples/0_Ball_Prediction/appearance.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions python/examples/0_Ball_Prediction/requirements.txt

This file was deleted.

73 changes: 0 additions & 73 deletions python/examples/0_Ball_Prediction/rlbot.cfg

This file was deleted.

9 changes: 0 additions & 9 deletions python/examples/0_Ball_Prediction/run.bat

This file was deleted.

38 changes: 0 additions & 38 deletions python/examples/0_Ball_Prediction/run.py

This file was deleted.

Loading

0 comments on commit 546c650

Please sign in to comment.