Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional param to allow user to choose a better eval state set in… #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions rocket_learn/rollout_generator/redis/redis_rollout_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from rlgym.gamelaunch import LaunchPreference
from rlgym.gym import Gym

from rlgym.utils.state_setters import DefaultState

import rocket_learn.agent.policy
import rocket_learn.utils.generate_episode
from rocket_learn.rollout_generator.redis.utils import _unserialize_model, MODEL_LATEST, WORKER_IDS, OPPONENT_MODELS, \
Expand Down Expand Up @@ -50,8 +52,11 @@ def __init__(self, redis: Redis, name: str, match: Match,
dynamic_gm=True, streamer_mode=False, send_gamestates=True,
send_obs=True, scoreboard=None, pretrained_agents=None,
human_agent=None, force_paging=False, auto_minimize=True,
local_cache_name=None, gamemode_weights=None, full_team_evaluations=False):
local_cache_name=None, gamemode_weights=None, full_team_evaluations=False,
eval_setter=DefaultState(),
):
# TODO model or config+params so workers can recreate just from redis connection?
self.eval_setter = eval_setter
self.redis = redis
self.name = name

Expand Down Expand Up @@ -334,7 +339,9 @@ def run(self): # Mimics Thread
if evaluate and not self.streamer_mode and self.human_agent is None:
print("Running evaluation game with versions:", version_info)
result = rocket_learn.utils.generate_episode.generate_episode(self.env, agents, evaluate=True,
scoreboard=self.scoreboard)
scoreboard=self.scoreboard,
eval_setter=self.eval_setter,
)
rollouts = []
print("Evaluation finished, goal differential:", result)
else:
Expand Down
6 changes: 3 additions & 3 deletions rocket_learn/utils/generate_episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rocket_learn.utils.dynamic_gamemode_setter import DynamicGMSetter


def generate_episode(env: Gym, policies, evaluate=False, scoreboard=None) -> (List[ExperienceBuffer], int):
def generate_episode(env: Gym, policies, evaluate=False, scoreboard=None, eval_setter=DefaultState()) -> (List[ExperienceBuffer], int):
"""
create experience buffer data by interacting with the environment(s)
"""
Expand All @@ -28,10 +28,10 @@ def generate_episode(env: Gym, policies, evaluate=False, scoreboard=None) -> (Li
env._match._terminal_conditions = [game_condition] # noqa
if isinstance(env._match._state_setter, DynamicGMSetter): # noqa
state_setter = env._match._state_setter.setter # noqa
env._match._state_setter.setter = DefaultState() # noqa
env._match._state_setter.setter = eval_setter # noqa
else:
state_setter = env._match._state_setter # noqa
env._match._state_setter = DefaultState() # noqa
env._match._state_setter = eval_setter # noqa

env._match._reward_fn = ConstantReward() # noqa Save some cpu cycles

Expand Down