example_envs.tag_continuous package¶
Submodules¶
example_envs.tag_continuous.generate_rollout_animation module¶
Helper file for generating an environment rollout
- example_envs.tag_continuous.generate_rollout_animation.generate_tag_env_rollout_animation(trainer, fps=50, tagger_color='#C843C3', runner_color='#245EB6', runner_not_in_game_color='#666666', fig_width=6, fig_height=6)¶
example_envs.tag_continuous.tag_continuous module¶
- class example_envs.tag_continuous.tag_continuous.TagContinuous(num_taggers=1, num_runners=10, grid_length=10.0, episode_length=100, starting_location_x=None, starting_location_y=None, starting_directions=None, seed=None, max_speed=1.0, skill_level_runner=1.0, skill_level_tagger=1.0, max_acceleration=1.0, min_acceleration=- 1.0, max_turn=1.5707963267948966, min_turn=- 1.5707963267948966, num_acceleration_levels=10, num_turn_levels=10, edge_hit_penalty=- 0.0, use_full_observation=True, num_other_agents_observed=2, tagging_distance=0.01, tag_reward_for_tagger=1.0, step_penalty_for_tagger=- 0.0, tag_penalty_for_runner=- 1.0, step_reward_for_runner=0.0, end_of_game_reward_for_runner=1.0, runner_exits_game_after_tagged=True, env_backend='cpu')¶
Bases:
warp_drive.utils.gpu_environment_context.CUDAEnvironmentContext
The game of tag on a continuous circular 2D space. There are some taggers trying to tag several runners. The taggers want to get as close as possible to the runner, while the runner wants to get as far away from them as possible. Once a runner is tagged, he exits the game if runner_exits_game_after_tagged is True otherwise he continues to run around (and the tagger can catch him again)
- compute_distance(agent1, agent2)¶
Note: ‘compute_distance’ is only used when running on CPU step() only. When using the CUDA step function, this Python method (compute_distance) is also part of the step() function!
- compute_reward()¶
Compute and return the rewards for each agent.
- generate_observation()¶
Generate and return the observations for every agent.
- get_data_dictionary()¶
Create a dictionary of data to push to the device
- get_tensor_dictionary()¶
- k_nearest_neighbors(agent_id, k)¶
Note: ‘k_nearest_neighbors’ is only used when running on CPU step() only. When using the CUDA step function, this Python method (k_nearest_neighbors) is also part of the step() function!
- name = 'TagContinuous'¶
- reset()¶
Env reset().
- seed(seed=None)¶
Seeding the environment with a desired seed Note: this uses the code in https://github.com/openai/gym/blob/master/gym/utils/seeding.py
- set_global_state(key=None, value=None, t=None, dtype=None)¶
Set the global state for a specified key, value and timestep. Note: for a new key, initialize global state to all zeros.
- step(actions=None)¶
Env step() - The GPU version calls the corresponding CUDA kernels
- update_state(delta_accelerations, delta_turns)¶
Note: ‘update_state’ is only used when running on CPU step() only. When using the CUDA step function, this Python method (update_state) is part of the step() function!
The logic below mirrors (part of) the step function in CUDA.