-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update example bots, improve python bindings & more (#37)
* 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
Showing
130 changed files
with
834 additions
and
9,534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 35 additions & 36 deletions
71
python/examples/0_Ball_Prediction/agent.py → python/examples/0_Ball_Prediction.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.