50.021 Artificial Intelligence Project
Code Setup to run VizDoom Agent Installing VizDoom Our project makes use of the external VizDoom library as it contains the source code for DOOM as well as additional C and Python libraries that serve to create the environment our agent will be trained and tested on.
To start, follow the instructions on the VizDoom Github to install the VizDoom Python library on your desired operating system. Generally, running the following line will install the library for the Windows operating system should your system have Python 3.7+:
# For vizdoom
pip install vizdoom
# Entire project Dependencies
pip install -r requirements.txt
Installing Project Agents To install the training and testing scenarios as well as the different agents of our project, in the desired directory on your system, clone the github repository:
git clone https://github.com/skerbos/AI_DOOM
Installing Additional Scenario There is an additional scenario that our model is trained on, which is the original DOOM map, specifically the first level, E1M1. To be able to access this environment when running the agents, install the DOOM.WAD file provided in the project github repository into the directory of your VizDoom Python library folder, for example:
C:\Users\[username]\AppData\Local\Programs\Python\Python310\Lib\site-package
s\vizdoom
Running Pretrained Models for Training and Testing There are 8 files that can be run:
train.py:
Runs the provided DQN Agent in the original DOOM map, E1M1
To view the trained DQN Agent playing the map, set the following variables as follows:
- save_model = false
- load_model = true
- skip_learning = true
train_acn.py:
Runs the Actor-Critic Agent in the original DOOM map, E1M1
To view the trained ACN Agent playing the map, set the following variables as follows:
- save_model = false
- load_model = true
- skip_learning = true
train_acn_center.py:
Runs the Actor-Critic Agent in the Defend the Center scenario
test_acn_center.py:
Runs a trained Actor-Critic Agent for testing and inference
It can be run by inputting the following command:
python test_acn_center.py [ckpt_path]
[ckpt_path] is the path to the Actor-Critic Agent checkpoint file
dq_defend_the_center.py:
Runs a DQN Agent in the Defend the Center scenario
dq_w_rewards_defend_the_center.py:
Runs a DQN Agent with custom rewards in the Defend the Center scenario
dq_w_rewards_defend_the_center_higher_frames.py:
Runs a DQN Agent with custom rewards and higher frame rate in the Defend the Center scenario
dq_w_rewards_E1M1.py:
Runs a DQN Agent with custom rewards in the original DOOM map, E1M1
For each of the files run, the following results will be obtained: The mean, minimum and maximum training scores for each training episode, of which the values are based on the reward obtained by the agent. A replay of the desired (10 by default) number of training episodes to visualize the actions taken by the agent in the game environment.
Visualization of Results There are 2 files that can be run:
logging_files.py:
Generates .csv log files based on the trained model save file.
The following variables can be changed:
- exp_name: Name for experiment conducted for training model
- model_savefile: File path and name for the trained model checkpoint
- test_path_csv: File path and name for output .csv log file
results_plotting.py:
Generates a graph based on the .csv log file generated by logging_files.py
The following variables can be changed:
- file_path: File path where output .csv log files are stored