All Projects β†’ glample β†’ Arnold

glample / Arnold

Arnold - DOOM Agent

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Arnold

Deep traffic
MIT DeepTraffic top 2% solution (75.01 mph) πŸš—.
Stars: ✭ 47 (-89.72%)
Mutual labels:  artificial-intelligence, reinforcement-learning, q-learning
Basic reinforcement learning
An introductory series to Reinforcement Learning (RL) with comprehensive step-by-step tutorials.
Stars: ✭ 826 (+80.74%)
Mutual labels:  artificial-intelligence, reinforcement-learning, q-learning
Rl4j
Deep Reinforcement Learning for the JVM (Deep-Q, A3C)
Stars: ✭ 330 (-27.79%)
Mutual labels:  artificial-intelligence, doom, reinforcement-learning
Notebooks
Some notebooks
Stars: ✭ 53 (-88.4%)
Mutual labels:  artificial-intelligence, reinforcement-learning, q-learning
Dinoruntutorial
Accompanying code for Paperspace tutorial "Build an AI to play Dino Run"
Stars: ✭ 285 (-37.64%)
Mutual labels:  reinforcement-learning, q-learning
Trading Bot
Stock Trading Bot using Deep Q-Learning
Stars: ✭ 273 (-40.26%)
Mutual labels:  reinforcement-learning, q-learning
Dreamerv2
Mastering Atari with Discrete World Models
Stars: ✭ 287 (-37.2%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Reinforcement Learning
Learn Deep Reinforcement Learning in 60 days! Lectures & Code in Python. Reinforcement Learning + Deep Learning
Stars: ✭ 3,329 (+628.45%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Evostra
A fast Evolution Strategy implementation in Python
Stars: ✭ 227 (-50.33%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Gdrl
Grokking Deep Reinforcement Learning
Stars: ✭ 304 (-33.48%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Pomdps.jl
MDPs and POMDPs in Julia - An interface for defining, solving, and simulating fully and partially observable Markov decision processes on discrete and continuous spaces.
Stars: ✭ 338 (-26.04%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Dreamer
Dream to Control: Learning Behaviors by Latent Imagination
Stars: ✭ 269 (-41.14%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Polyaxon
Machine Learning Platform for Kubernetes (MLOps tools for experimentation and automation)
Stars: ✭ 2,966 (+549.02%)
Mutual labels:  artificial-intelligence, reinforcement-learning
He4o
ε’ŒοΌˆhe for objective-cοΌ‰ β€”β€” β€œδΏ‘ζ―η†΅ε‡ζœΊη³»η»Ÿβ€
Stars: ✭ 284 (-37.86%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Applied Reinforcement Learning
Reinforcement Learning and Decision Making tutorials explained at an intuitive level and with Jupyter Notebooks
Stars: ✭ 229 (-49.89%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Lagom
lagom: A PyTorch infrastructure for rapid prototyping of reinforcement learning algorithms.
Stars: ✭ 364 (-20.35%)
Mutual labels:  artificial-intelligence, reinforcement-learning
Qtrader
Reinforcement Learning for Portfolio Management
Stars: ✭ 363 (-20.57%)
Mutual labels:  reinforcement-learning, q-learning
Reinforcement learning tutorial with demo
Reinforcement Learning Tutorial with Demo: DP (Policy and Value Iteration), Monte Carlo, TD Learning (SARSA, QLearning), Function Approximation, Policy Gradient, DQN, Imitation, Meta Learning, Papers, Courses, etc..
Stars: ✭ 442 (-3.28%)
Mutual labels:  reinforcement-learning, q-learning
Awesome Monte Carlo Tree Search Papers
A curated list of Monte Carlo tree search papers with implementations.
Stars: ✭ 387 (-15.32%)
Mutual labels:  reinforcement-learning, q-learning
Dm control
DeepMind's software stack for physics-based simulation and Reinforcement Learning environments, using MuJoCo.
Stars: ✭ 2,592 (+467.18%)
Mutual labels:  artificial-intelligence, reinforcement-learning

Arnold

Arnold is a PyTorch implementation of the agent presented in Playing FPS Games with Deep Reinforcement Learning (https://arxiv.org/abs/1609.05521), and that won the 2017 edition of the ViZDoom AI Competition.

example

This repository contains:

  • The source code to train DOOM agents
  • A package with 17 selected maps that can be used for training and evaluation
  • 5 pretrained models that you can visualize and play against, including the ones that won the ViZDoom competition

Installation

Dependencies

Arnold was tested successfully on Mac OS and Linux distributions. You will need:

  • Python 2/3 with NumPy and OpenCV
  • PyTorch
  • ViZDoom

Follow the instructions on https://github.com/mwydmuch/ViZDoom to install ViZDoom. Be sure that you can run import vizdoom in Python from any directory. To do so, you can either install the library with pip, or compile it, then move it to the site-packages directory of your Python installation, as explained here: https://github.com/mwydmuch/ViZDoom/blob/master/doc/Quickstart.md.

Code structure

.
β”œβ”€β”€ pretrained                    # Examples of pretrained models
β”œβ”€β”€ resources
    β”œβ”€β”€ freedoom2.wad             # DOOM resources file (containing all textures)
    └── scenarios                 # Folder containing all scenarios
        β”œβ”€β”€ full_deathmatch.wad   # Scenario containing all deathmatch maps
        β”œβ”€β”€ health_gathering.wad  # Simple test scenario
        └── ...
β”œβ”€β”€ src                           # Source files
    β”œβ”€β”€ doom                      # Game interaction / API / scenarios
    β”œβ”€β”€ model                     # DQN / DRQN implementations
    └── trainer                   # Folder containing training scripts
β”œβ”€β”€ arnold.py                     # Main file
└── README.md

Scenarios / Maps

Train a model

There are many parameters you can tune to train a model.

python arnold.py

## General parameters about the game
--freedoom "true"                # use freedoom resources
--height 60                      # screen height
--width 108                      # screen width
--gray "false"                   # use grayscale screen
--use_screen_buffer "true"       # use the screen buffer (what the player sees)
--use_depth_buffer "false"       # use the depth buffer
--labels_mapping ""              # use extra feature maps for specific objects
--game_features "target,enemy"   # game features prediction (auxiliary tasks)
--render_hud "false"             # render the HUD (status bar in the bottom of the screen)
--render_crosshair "true"        # render crosshair (targeting aid in the center of the screen)
--render_weapon "true"           # render weapon
--hist_size 4                    # history size
--frame_skip 4                   # frame skip (1 = keep every frame)

## Agent allowed actions
--action_combinations "attack+move_lr;turn_lr;move_fb"  # agent allowed actions
--freelook "false"               # allow the agent to look up and down
--speed "on"                     # make the agent run
--crouch "off"                   # make the agent crouch

## Training parameters
--batch_size 32                  # batch size
--replay_memory_size 1000000     # maximum number of frames in the replay memory
--start_decay 0                  # epsilon decay iteration start
--stop_decay 1000000             # epsilon decay iteration end
--final_decay 0.1                # final epsilon value
--gamma 0.99                     # discount factor gamma
--dueling_network "false"        # use a dueling architecture
--clip_delta 1.0                 # clip the delta loss
--update_frequency 4             # DQN update frequency
--dropout 0.5                    # dropout on CNN output layer
--optimizer "rmsprop,lr=0.0002"  # network optimizer

## Network architecture
--network_type "dqn_rnn"         # network type (dqn_ff / dqn_rnn)
--recurrence "lstm"              # recurrent network type (rnn / gru / lstm)
--n_rec_layers 1                 # number of layers in the recurrent network
--n_rec_updates 5                # number of updates by sample
--remember 1                     # remember all frames during evaluation
--use_bn "off"                   # use BatchNorm when processing the screen
--variable_dim "32"              # game variables embeddings dimension
--bucket_size "[10, 1]"          # bucket game variables (typically health / ammo)
--hidden_dim 512                 # hidden layers dimension

## Scenario parameters (these parameters will differ based on the scenario)
--scenario "deathmatch"          # scenario
--wad "full_deathmatch"          # WAD file (scenario file)
--map_ids_train "2,3,4,5"        # maps to train the model
--map_ids_test "6,7,8"           # maps to test the model
--n_bots 8                       # number of enemy bots
--randomize_textures "true"      # randomize walls / floors / ceils textures during training
--init_bots_health 20            # reduce initial life of enemy bots (helps a lot when using pistol)

## Various
--exp_name new_train             # experiment name
--dump_freq 200000               # periodically dump the model
--gpu_id -1                      # GPU ID (-1 to run on CPU)

Once your agent is trained, you can visualize it by running the same command, and using the following extra arguments:

--visualize 1                    # visualize the model (render the screen)
--evaluate 1                     # evaluate the agent
--manual_control 1               # manually make the agent turn about when it gets stuck
--reload PATH                    # path where the trained agent was saved

Here are some examples of training commands for 3 different scenarios:

Defend the center

In this scenario the agent is in the middle of a circular map. Monsters are regularly appearing on the sides and are walking towards the agent. The agent is given a pistol and limited ammo, and must turn around and kill the monsters before they reach it. The following command trains a standard DQN, that should reach the optimal performance of 56 frags (the number of bullets in the pistol) in about 4 million steps:

python arnold.py --scenario defend_the_center --action_combinations "turn_lr+attack" --frame_skip 2

Health gathering

In this scenario the agent is walking on lava, and is losing health points at each time step. The agent has to move and collect as many health pack as possible in order to survive. The objective is to survive the longest possible time.

python arnold.py --scenario health_gathering --action_combinations "move_fb;turn_lr" --frame_skip 5

This scenario is very easy and the model quickly reaches the maximum survival time of 2 minutes (35 * 120 = 4200 frames). The scenario also provides a supreme mode, in which the map is more complicated and where the health packs are much harder to collect:

python arnold.py --scenario health_gathering --action_combinations "move_fb;turn_lr" --frame_skip 5 --supreme 1

In this scenario, the agent takes about 1.5 million steps to reach the maximum survival time (but often dies before the end).

Deathmatch

In this scenario, the agent is trained to fight against the built-in bots of the game. Here is a command to train the agent using game features prediction (as described in [1]), and a DRQN:

python arnold.py --scenario deathmatch --wad deathmatch_rockets --n_bots 8 \
--action_combinations "move_fb;move_lr;turn_lr;attack" --frame_skip 4 \
--game_features "enemy" --network_type dqn_rnn --recurrence lstm --n_rec_updates 5

Pretrained models

Defend the center / Health gathering

We provide a pretrained model for each of these scenarios. You can visualize them by running:

./run.sh defend_the_center

or

./run.sh health_gathering

Visual Doom AI Competition 2017

We release the two agents submitted to the first and second tracks of the ViZDoom AI 2017 Competition. You can visualize them playing against the built-in bots using the following commands:

Track 1 - Arnold vs 10 built-in AI bots
./run.sh track1 --n_bots 10
Track 2 - Arnold vs 10 built-in AI bots - Map 2
./run.sh track2 --n_bots 10 --map_id 2
Track 2 - 4 Arnold playing against each other - Map 3
./run.sh track2 --n_bots 0 --map_id 3 --n_agents 4

We also trained an agent on a single map, using a same weapon (the SuperShotgun). This agent is extremely difficult to beat.

Shotgun - 4 Arnold playing against each other
./run.sh shotgun --n_bots 0 --n_agents 4
Shotgun - 3 Arnold playing against each other + 1 human player (to play against the agent)
./run.sh shotgun --n_bots 0 --n_agents 3 --human_player 1

References

If you found this code useful, please consider citing:

[1] G. Lample* and D.S. Chaplot*, Playing FPS Games with Deep Reinforcement Learning

@inproceedings{lample2017playing,
  title={Playing FPS Games with Deep Reinforcement Learning.},
  author={Lample, Guillaume and Chaplot, Devendra Singh},
  booktitle={Proceedings of AAAI},
  year={2017}
}

[2] D.S. Chaplot* and G. Lample*, Arnold: An Autonomous Agent to Play FPS Games

@inproceedings{chaplot2017arnold,
  title={Arnold: An Autonomous Agent to Play FPS Games.},
  author={Chaplot, Devendra Singh and Lample, Guillaume},
  booktitle={Proceedings of AAAI},
  year={2017},
  Note={Best Demo award}
}

Acknowledgements

We acknowledge the developers of ViZDoom for constant help and support during the development of this project. Some of the maps and wad files have been borrowed from the ViZDoom git repository. We also thank the members of the ZDoom community for their help with the Action Code Scripts (ACS).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].