Skip to content

Commit

Permalink
Enhanced State Setters (#31)
Browse files Browse the repository at this point in the history
* added WallSetter v1

* shots are more like airdribbles and fixed backboard defense bug

* update version

* removed testing code

* updated version log

* removed debug code
  • Loading branch information
DanielDowns authored Mar 31, 2022
1 parent 0b4ce2f commit e8b0a68
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
18 changes: 13 additions & 5 deletions rlgym_tools/extra_state_setters/goalie_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _get_shot_parameters(self, team_turn, aerial_only):
x_pos = random.uniform(GOAL_X_MIN, GOAL_X_MAX)

# if its not an air shot, we can randomize the shot speed
shot_randomizer = 1 if aerial_only else (random.uniform(.2, 1))
shot_randomizer = 1 if aerial_only else (random.uniform(.6, 1))

y_vel = (3000 * INVERT_IF_BLUE) if aerial_only else (3000 * shot_randomizer * INVERT_IF_BLUE)
if shotpick == 0: # long range shot
Expand All @@ -152,16 +152,24 @@ def _get_shot_parameters(self, team_turn, aerial_only):
elif shotpick == 2: # angled shot
z_pos = 1500 if aerial_only else random.uniform(100, 1500)
x_pos += 3200 # add offset to start the shot from the side
y_pos = -2000 * INVERT_IF_BLUE

pos = np.array([x_pos, 0, z_pos])
lin_vel = np.array([-1900 * shot_randomizer, y_vel, 0])
x_vel = -1100
y_vel = 2500 * INVERT_IF_BLUE

pos = np.array([x_pos, y_pos, z_pos])
lin_vel = np.array([x_vel, y_vel, 650])

elif shotpick == 3: # opposite angled shot
z_pos = 1500 if aerial_only else random.uniform(100, 1500)
x_pos -= 3200 # add offset to start the shot from the other side
y_pos = 2000 * INVERT_IF_BLUE

x_vel = 1100
y_vel = -2500 * INVERT_IF_BLUE

pos = np.array([x_pos, 0, z_pos])
lin_vel = np.array([1900 * shot_randomizer, y_vel, 0])
pos = np.array([x_pos, y_pos, z_pos])
lin_vel = np.array([x_vel, y_vel, 650])
else:
print("FAULT")

Expand Down
9 changes: 6 additions & 3 deletions rlgym_tools/extra_state_setters/wall_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,21 @@ def _side_high_roll(self, state_wrapper):
wall_car_blue.set_pos(blue_x, blue_y, blue_z)
wall_car_blue.boost = 100


#orange car setup
orange_pitch_rot = 0 * DEG_TO_RAD
orange_yaw_rot = -90 * DEG_TO_RAD
orange_roll_rot = -90 * side_inverter * DEG_TO_RAD
wall_car_orange.set_rot(orange_pitch_rot, orange_yaw_rot, orange_roll_rot)


orange_x = 4096 * side_inverter
orange_y = 2500 + (random.randrange(500) - 250)
orange_z = 400 + (random.randrange(400) - 200)
wall_car_orange.set_pos(orange_x, orange_y, orange_z)
wall_car_orange.boost = 100


for car in state_wrapper.cars:
if car is wall_car_orange or car is wall_car_blue:
continue
Expand All @@ -98,7 +101,7 @@ def _short_goal_roll(self, state_wrapper):
sidepick = random.randrange(2)

defense_inverter = 1
if defense_team == 1:
if defense_team == 0:
# change side
defense_inverter = -1

Expand All @@ -112,10 +115,10 @@ def _short_goal_roll(self, state_wrapper):
x_random = random.randrange(446)
ball_x_pos = (-2850 + x_random) * side_inverter
ball_y_pos = (5120 - BALL_RADIUS) * defense_inverter
ball_z_pos = 1400
ball_z_pos = 1400 + random.randrange(400) - 200
state_wrapper.ball.set_pos(ball_x_pos, ball_y_pos, ball_z_pos)

ball_x_vel = 1000 * side_inverter
ball_x_vel = (1000 + random.randrange(400) - 200) * side_inverter
ball_y_vel = 0
ball_z_vel = 550
state_wrapper.ball.set_lin_vel(ball_x_vel, ball_y_vel, ball_z_vel)
Expand Down
7 changes: 6 additions & 1 deletion rlgym_tools/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
# 3) we can import it into your module module
# https://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package

__version__ = '1.6.4'
__version__ = '1.6.5'

release_notes = {
'1.6.5':
"""
-GoalieStateSetter now better emulates incoming airdribbles
-fixed WallStateSetter bug and increased starting diversity
""",
'1.6.4':
"""
-Added wall play state setter (Soren)
Expand Down

0 comments on commit e8b0a68

Please sign in to comment.