Skip to content

Commit

Permalink
just testing things
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiyotech committed May 5, 2023
1 parent 4589b28 commit 287972c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
23 changes: 17 additions & 6 deletions sim_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
import numpy as np
from rlgym_sim.utils.terminal_conditions.common_conditions import GoalScoredCondition, TimeoutCondition

setter = AugmentSetter(ReplaySetter("replays/easy_double_tap_1v0.npy", defender_front_goal_weight=0.2,
random_boost=True, print_choice=True, override=1),
bad_list = []
index = {}
setter = AugmentSetter(ReplaySetter("replays/easy_double_tap_1v1.npy", defender_front_goal_weight=0.2,
random_boost=True, print_choice=True, override=None, index=index),
True, False, False)
parser = CoyoteAction()
obs = TestObs()
reward = TestReward()
terminals = [GoalScoredCondition(), TimeoutCondition(100)]

env = rlgym_sim.make(tick_skip=4, spawn_opponents=False, state_setter=setter, copy_gamestate_every_step=True,
env = rlgym_sim.make(tick_skip=4, spawn_opponents=True, state_setter=setter, copy_gamestate_every_step=True,
action_parser=parser, obs_builder=obs, reward_fn=reward, terminal_conditions=terminals)

total_steps = 0
Expand All @@ -34,12 +36,21 @@
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((np.asarray([0]), np.asarray([np.random.randint(0, 373)])))
# actions = np.asarray(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")
if index[0] not in bad_list:
bad_list.append(index[0])
# input()
break
steps += 1
total_steps += steps
print(f"completed {steps} steps. Starting new episode. Done {total_steps} total steps")
print(bad_list)
# print(f"completed {steps} steps. Starting new episode. Done {total_steps} total steps")


36 changes: 19 additions & 17 deletions test_files/test_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(self, pos_coef=1 / 2300, ang_coef=1 / math.pi, lin_vel_coef=1 / 230
self.steps = 0
self.actions = deque(maxlen=50)


def reset(self, initial_state: GameState):
self.states.clear()
self.actions.clear()
Expand Down Expand Up @@ -111,23 +112,24 @@ def build_obs(self, player: PlayerData, state: GameState, previous_action: np.nd
# obs = obs.flatten()
# obs = np.expand_dims(np.fromiter(obs, dtype=np.float32, count=len(obs)), 0)
obs = np.concatenate(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" {self.steps} since reset")
i = 0
for each_state in self.states:
print(i)
i += 1
print_state(each_state)
print("printing actions")
i = 0
for each_action in self.actions:
print(i)
i += 1
print(each_action)
exit()
# if np.isnan(obs).any():
# # self.actions.reverse()
# # self.states.reverse()
# print(f"There is a nan in the obs. Printing states")
# input()
# print(f" {self.steps} since reset")
# i = 0
# for each_state in self.states:
# print(i)
# i += 1
# print_state(each_state)
# print("printing actions")
# i = 0
# for each_action in self.actions:
# print(i)
# i += 1
# print(each_action)
# exit()
return obs

def _add_player_to_obs(self, obs: List, player: PlayerData, inverted: bool):
Expand Down

0 comments on commit 287972c

Please sign in to comment.