Skip to content

Commit

Permalink
remove defender weight replay causing issues with dtap
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiyotech committed May 6, 2023
1 parent c8551c2 commit d85e4c2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
4 changes: 2 additions & 2 deletions setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ def __init__(self, mode, end_object_choice=None, simulator=False):
for i in range(4):
self.setters.append(
WeightedSampleSetter(
(AugmentSetter(ReplaySetter(double_tap_replays[i], defender_front_goal_weight=0.2,
(AugmentSetter(ReplaySetter(double_tap_replays[i], defender_front_goal_weight=0,
random_boost=True, print_choice=True),
True, False, False),
AugmentSetter(ReplaySetter(easy_double_tap_replays[i], defender_front_goal_weight=0.2,
AugmentSetter(ReplaySetter(easy_double_tap_replays[i], defender_front_goal_weight=0,
random_boost=True, print_choice=True),
True, False, False),
), (0.2, 0.8))
Expand Down
8 changes: 5 additions & 3 deletions sim_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
setter = AugmentSetter(ReplaySetter("replays/double_tap_1v1.npy", defender_front_goal_weight=0,
random_boost=True, print_choice=True, override=None, index=index),
True, False, False)
# setter = ReplaySetter("replays/bad_1v1_doubletap_state.npy")
parser = CoyoteAction()
obs = TestObs()
reward = TestReward()
Expand All @@ -36,21 +37,22 @@
done = False
steps = 0
while not done:
actions = np.asarray((np.asarray([0]), np.asarray([np.random.randint(0, 373)])))
#actions = np.asarray((np.asarray([0]), np.asarray([np.random.randint(0, 373)])))
# actions = np.asarray(np.asarray([0],))
actions = np.asarray((np.asarray([0]), np.asarray([0])))
new_obs, reward, done, state = env.step(actions)
obs = new_obs
if np.isnan(obs).any():
# self.actions.reverse()
# self.states.reverse()
print(f"There is a nan in the obs. Printing states")
print(f"There is a nan in the obs. Printing states after {steps} steps")
if index[0] not in bad_list:
bad_list.append(index[0])
# input()
break
steps += 1
total_steps += steps
print(bad_list)
# print(f"completed {steps} steps. Starting new episode. Done {total_steps} total steps")
print(f"completed {steps} steps. Starting new episode. Done {total_steps} total steps")


40 changes: 40 additions & 0 deletions sim_tester_minimal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import rlgym_sim
# from CoyoteParser import CoyoteAction
from rlgym_tools.extra_state_setters.replay_setter import ReplaySetter
# from rlgym_tools.extra_state_setters.augment_setter import AugmentSetter
# from test_files.test_obs import TestObs
# from test_files.test_reward import TestReward
import numpy as np
from rlgym_sim.utils.terminal_conditions.common_conditions import GoalScoredCondition, TimeoutCondition

bad_list = []
index = {}
setter = ReplaySetter("replays/bad_1v1_doubletap_state.npy")
# obs = TestObs()
# reward = TestReward()
terminals = [GoalScoredCondition(), TimeoutCondition(100)]

env = rlgym_sim.make(tick_skip=4, spawn_opponents=True, state_setter=setter, copy_gamestate_every_step=True,
terminal_conditions=terminals)

total_steps = 0

while True:
obs = env.reset()
done = False
steps = 0
while not done:
# actions = np.asarray((np.asarray([0]), np.asarray([np.random.randint(0, 373)])))
# actions = np.asarray(np.asarray([0],))
# actions = np.asarray([0] * 8), np.asarray([0] * 8)
actions = np.asarray([1, 0.5, 0.5, 0.5, 0, 0, 1, 0]), np.asarray([1, 0.5, 0.5, 0.5, 0, 0, 1, 0])
new_obs, reward, done, state = env.step(actions)
obs = new_obs
if np.isnan(obs).any():
print(f"There is a nan in the obs after {steps} steps.")
break
steps += 1
total_steps += steps
print(f"completed {steps} steps. Starting new episode. Done {total_steps} total steps")


0 comments on commit d85e4c2

Please sign in to comment.