Skip to content

Commit

Permalink
Added use_item and removed prints.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicEastvillage committed Jul 2, 2019
1 parent c708d33 commit 7dfe929
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
25 changes: 17 additions & 8 deletions beastbot/beastbot.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import random
import time

from RLUtilities.Maneuvers import AirDodge
from rlbot.agents.base_agent import BaseAgent, SimpleControllerState
from rlbot.utils.game_state_util import CarState, Physics, Vector3, Rotator, GameState
from rlbot.utils.structures.game_data_struct import GameTickPacket

import moves
from behaviour import *
from info import EGameInfo
from moves import DriveController, AimCone, ShotController
from plans import KickoffPlan, SmallJumpPlan, choose_kickoff_plan
from plans import choose_kickoff_plan
from render import FakeRenderer, draw_ball_path
from rlmath import *
from utsystem import UtilitySystem

RENDER = True
RENDER = False


class Beast(BaseAgent):
Expand Down Expand Up @@ -90,7 +85,7 @@ def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
self.info.my_car.last_input.boost = self.controls.boost

self.renderer.end_rendering()
return self.controls
return fix_controls(self.controls)

def print(self, s):
team_name = "[BLUE]" if self.team == 0 else "[ORANGE]"
Expand All @@ -112,6 +107,20 @@ def random_color(self, anything):
return color_functions.get(hash(anything) % 10)()


def fix_controls(controls):
return SimpleControllerState(
steer=controls.steer,
throttle=controls.throttle,
pitch=controls.pitch,
yaw=controls.yaw,
roll=controls.roll,
jump=controls.jump,
boost=controls.boost,
handbrake=controls.handbrake,
use_item=False
)


class DefaultBehaviour:
def __init__(self):
pass
Expand Down
2 changes: 0 additions & 2 deletions beastbot/behaviour.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from RLUtilities.Simulation import Car, Input

import predict
import render
from moves import AimCone
Expand Down
1 change: 0 additions & 1 deletion beastbot/info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from RLUtilities.GameInfo import GameInfo, BoostPad
from RLUtilities.Simulation import Car
from rlbot.messages.flat import GameTickPacket, FieldInfo

from rlmath import *
Expand Down
13 changes: 0 additions & 13 deletions beastbot/plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def choose_kickoff_plan(bot):

# Do we have teammates? If no -> always go for kickoff
if len(bot.info.teammates) == 0:
bot.print("No team mates, early conclusion")
return KickoffPlan()

# Kickoff spawn locations (corners may vary from map to map)
Expand All @@ -246,60 +245,48 @@ def choose_kickoff_plan(bot):
if is_my_kickoff_spawn(bot, right_corner_loc):
tm_index = index_of_teammate_at_kickoff_spawn(bot, left_corner_loc)
if 0 <= tm_index < bot.index:
bot.print("SecondMan right")
return SecondManSlowCornerKickoffPlan(bot)
else:
bot.print("FirstMan right")
return KickoffPlan()
if is_my_kickoff_spawn(bot, left_corner_loc):
tm_index = index_of_teammate_at_kickoff_spawn(bot, right_corner_loc)
if 0 <= tm_index < bot.index:
bot.print("SecondMan left")
return SecondManSlowCornerKickoffPlan(bot)
else:
bot.print("FirstMan left")
return KickoffPlan()

# Is a teammate in the corner -> collect boost
if 0 <= index_of_teammate_at_kickoff_spawn(bot, right_corner_loc) \
or 0 <= index_of_teammate_at_kickoff_spawn(bot, left_corner_loc):
if bot.info.my_car.pos[X] > 10:
# go for left boost
bot.print("Boost left, because team mate corner")
return CollectSpecificBoostPlan(vec3(boost_x, boost_y, 0))
if bot.info.my_car.pos[X] < -10:
# go for right boost
bot.print("Boost right, because team mate corner")
return CollectSpecificBoostPlan(vec3(-boost_x, boost_y, 0))
if 0 <= index_of_teammate_at_kickoff_spawn(bot, back_right_loc):
# go for left boost
bot.print("Boost left, because team mate back right")
return CollectSpecificBoostPlan(vec3(boost_x, boost_y, 0))
else:
# go for right boost
bot.print("Boost right, because team mate back left")
return CollectSpecificBoostPlan(vec3(-boost_x, boost_y, 0))

# No teammate in the corner
# Are we back right or left -> go for kickoff
if is_my_kickoff_spawn(bot, back_right_loc)\
or is_my_kickoff_spawn(bot, back_left_loc):
bot.print("Kickoff, back side")
return KickoffPlan()

# No teammate in the corner
# Is a teammate back right or left -> collect boost
if 0 <= index_of_teammate_at_kickoff_spawn(bot, back_right_loc):
# go for left boost
bot.print("Boost left, im back")
return CollectSpecificBoostPlan(vec3(boost_x, boost_y, 0))
elif 0 <= index_of_teammate_at_kickoff_spawn(bot, back_left_loc):
# go for right boost
bot.print("Boost right, im back")
return CollectSpecificBoostPlan(vec3(-boost_x, boost_y, 0))

# We have no teammates
bot.print("No team mates")
return KickoffPlan()


Expand Down

0 comments on commit 7dfe929

Please sign in to comment.