--- library_name: rl-algo-impls tags: - MicrortsDefeatCoacAIShaped-v3 - ppo - deep-reinforcement-learning - reinforcement-learning model-index: - name: ppo results: - metrics: - type: mean_reward value: 0.77 +/- 0.64 name: mean_reward task: type: reinforcement-learning name: reinforcement-learning dataset: name: MicrortsDefeatCoacAIShaped-v3 type: MicrortsDefeatCoacAIShaped-v3 --- # **PPO** Agent playing **MicrortsDefeatCoacAIShaped-v3** This is a trained model of a **PPO** agent playing **MicrortsDefeatCoacAIShaped-v3** using the [/sgoodfriend/rl-algo-impls](https://github.com/sgoodfriend/rl-algo-impls) repo. All models trained at this commit can be found at https://api.wandb.ai/links/sgoodfriend/sjo3qukl. ## Training Results This model was trained from 3 trainings of **PPO** agents using different initial seeds. These agents were trained by checking out [9ba0ab5](https://github.com/sgoodfriend/rl-algo-impls/tree/9ba0ab50894e5cea207289f4af8b53cbafa47748). The best and last models were kept from each training. This submission has loaded the best models from each training, reevaluates them, and selects the best model from these latest evaluations (mean - std). | algo | env | seed | reward_mean | reward_std | eval_episodes | best | wandb_url | |:-------|:------------------------------|-------:|--------------:|-------------:|----------------:|:-------|:-----------------------------------------------------------------------------| | ppo | MicrortsDefeatCoacAIShaped-v3 | 1 | 0.769231 | 0.638971 | 26 | * | [wandb](https://wandb.ai/sgoodfriend/rl-algo-impls-benchmarks/runs/a0smxvhw) | | ppo | MicrortsDefeatCoacAIShaped-v3 | 2 | 0.692308 | 0.721602 | 26 | | [wandb](https://wandb.ai/sgoodfriend/rl-algo-impls-benchmarks/runs/8ees317u) | | ppo | MicrortsDefeatCoacAIShaped-v3 | 3 | 0.423077 | 0.884615 | 26 | | [wandb](https://wandb.ai/sgoodfriend/rl-algo-impls-benchmarks/runs/ifj50v2t) | ### Prerequisites: Weights & Biases (WandB) Training and benchmarking assumes you have a Weights & Biases project to upload runs to. By default training goes to a rl-algo-impls project while benchmarks go to rl-algo-impls-benchmarks. During training and benchmarking runs, videos of the best models and the model weights are uploaded to WandB. Before doing anything below, you'll need to create a wandb account and run `wandb login`. ## Usage /sgoodfriend/rl-algo-impls: https://github.com/sgoodfriend/rl-algo-impls Note: While the model state dictionary and hyperaparameters are saved, the latest implementation could be sufficiently different to not be able to reproduce similar results. You might need to checkout the commit the agent was trained on: [9ba0ab5](https://github.com/sgoodfriend/rl-algo-impls/tree/9ba0ab50894e5cea207289f4af8b53cbafa47748). ``` # Downloads the model, sets hyperparameters, and runs agent for 3 episodes python enjoy.py --wandb-run-path=sgoodfriend/rl-algo-impls-benchmarks/a0smxvhw ``` Setup hasn't been completely worked out yet, so you might be best served by using Google Colab starting from the [colab_enjoy.ipynb](https://github.com/sgoodfriend/rl-algo-impls/blob/main/colab_enjoy.ipynb) notebook. ## Training If you want the highest chance to reproduce these results, you'll want to checkout the commit the agent was trained on: [9ba0ab5](https://github.com/sgoodfriend/rl-algo-impls/tree/9ba0ab50894e5cea207289f4af8b53cbafa47748). While training is deterministic, different hardware will give different results. ``` python train.py --algo ppo --env MicrortsDefeatCoacAIShaped-v3 --seed 1 ``` Setup hasn't been completely worked out yet, so you might be best served by using Google Colab starting from the [colab_train.ipynb](https://github.com/sgoodfriend/rl-algo-impls/blob/main/colab_train.ipynb) notebook. ## Benchmarking (with Lambda Labs instance) This and other models from https://api.wandb.ai/links/sgoodfriend/sjo3qukl were generated by running a script on a Lambda Labs instance. In a Lambda Labs instance terminal: ``` git clone git@github.com:sgoodfriend/rl-algo-impls.git cd rl-algo-impls bash ./lambda_labs/setup.sh wandb login bash ./lambda_labs/benchmark.sh [-a {"ppo a2c dqn vpg"}] [-e ENVS] [-j {6}] [-p {rl-algo-impls-benchmarks}] [-s {"1 2 3"}] ``` ### Alternative: Google Colab Pro+ As an alternative, [colab_benchmark.ipynb](https://github.com/sgoodfriend/rl-algo-impls/tree/main/benchmarks#:~:text=colab_benchmark.ipynb), can be used. However, this requires a Google Colab Pro+ subscription and running across 4 separate instances because otherwise running all jobs will exceed the 24-hour limit. ## Hyperparameters This isn't exactly the format of hyperparams in hyperparams/ppo.yml, but instead the Wandb Run Config. However, it's very close and has some additional data: ``` additional_keys_to_log: - microrts_stats - microrts_results algo: ppo algo_hyperparams: batch_size: 3072 clip_range: 0.1 clip_range_decay: none clip_range_vf: 0.1 ent_coef: 0.01 gamma_end: 0.999 learning_rate: 0.00025 learning_rate_decay: spike max_grad_norm: 0.5 n_epochs: 4 n_steps: 512 ppo2_vf_coef_halving: true vf_coef: 0.5 device: auto env: Microrts-selfplay-unet-decay env_hyperparams: env_type: microrts make_kwargs: map_paths: - maps/16x16/basesWorkers16x16.xml max_steps: 4000 num_selfplay_envs: 36 render_theme: 2 reward_weight: - 10 - 1 - 1 - 0.2 - 1 - 4 n_envs: 24 self_play_kwargs: num_old_policies: 12 save_steps: 300000 swap_steps: 6000 swap_window_size: 4 window: 33 env_id: MicrortsDefeatCoacAIShaped-v3 eval_hyperparams: deterministic: false env_overrides: bots: coacAI: 2 droplet: 2 guidedRojoA3N: 2 izanagi: 2 lightRushAI: 2 mixedBot: 2 naiveMCTSAI: 2 passiveAI: 2 randomAI: 2 randomBiasedAI: 2 rojo: 2 tiamat: 2 workerRushAI: 2 make_kwargs: map_paths: - maps/16x16/basesWorkers16x16.xml max_steps: 4000 num_selfplay_envs: 0 render_theme: 2 reward_weight: - 1 - 0 - 0 - 0 - 0 - 0 n_envs: 26 self_play_kwargs: {} max_video_length: 4000 n_episodes: 26 score_function: mean step_freq: 1000000 microrts_reward_decay_callback: true n_timesteps: 300000000 policy_hyperparams: activation_fn: relu actor_head_style: unet cnn_flatten_dim: 256 cnn_style: microrts v_hidden_sizes: - 256 - 128 seed: 1 use_deterministic_algorithms: true wandb_entity: null wandb_group: null wandb_project_name: rl-algo-impls-benchmarks wandb_tags: - benchmark_9ba0ab5 - host_192-9-155-233 - branch_main - v0.0.9 ```