Tensorflow implementation of Artificial Intelligence in game Limbo.
Works only on Windows.
Consists of 4 neural networks: AutoEncoder (AE), Object Detection (OD), Supervised Learning (SL) and Reinforcement Learning(RL).
You can try to collect data and train models yourself. Or you can download pretrained models (see below). Reinforcement Learning part doesn't work now (converges to one action too quickly or doesn't learn at all).
- In
collect_data/collect.py
changeDATASET_FOLDER
to output folder. Also changeSCREEN_REGION
to match your resolution. - If you're playing in windowed mode you can find coordinates of screen with
python utils/show_coords.py
. - Start script using
python collect_data/collect.py
. To pause/unpause recording hitP
key. - This will create npy files consisting of list of <frame,action,reward>. Rewards are created using Optical Flow. Moving right leads to positive rewards, left - negative.
- To extract images from npy files run
python utils/npy2images.py
. ChangeNPY_FOLDER_PATH
to path of recorded npy frames andOUTPUT_FOLDER_PATH
to output path.
Check OD_training
folder.
- In
AE_create_dataset.py
changeINPUT_DIR
to path to your collected dataset folder. AndOUTPUT_DIR
to output folder. - Create dataset for Autoencoder using
python AE_create_dataset.py
. - In
AE_training.py
changedataset_dir
to path to your dataset (got from 2nd step). - Start training by
python AE_training.py
. - To check progress access tensorboad by
tensorboard --logdir path_to_this_repo/logdir/AE
- In
SL_create_dataset.py
changeDATASET_PATH
to path to dataset. Dataset must be in particular format. Root folder must containEXPERT
andBASIC
folders. In each folder there should be folders of games (one folder = one game). Each game folder must contain files namedD0.npy,D1.npy,...
. Also changeOUTPUT_DATASET_PATH
to output directory. - In
SL_create_dataset.py
changeOD_init
to full path tologdir/OD
if needed. Also changeAE_init
tologdir/AE/{any_params}/saved_model/model.ckpt
if needed. - Create dataset using
python SL_create_dataset.py
- In
SL_training.py
changedatasets_path
to dataset path containingEXPERT.npy
andBASIC.npy
(output of 3rd step). To continue training changeinit_model_path
to path of saved model.
DOESNT WORK NOW
(converges to one action too quickly or doesn't learn at all)
- Download zip from logdir.zip.
- Replace
logdir
folder with folder inside downloaded zip file.
- In
test_agent.py
changeOD_init
to frozen_graph folderlogdir/OD
. Also changeAE_init
andSL_init
to paths to saved models (tomodel.ckpt
). - Change
SCREEN_REGION
(frame that is fed through networks) andRECORD_REGION
(frame that is recorded for gif images) to match your needs. - Change other parameters to match previous trained networks (if params in previous models were changed).
- To watch value-function in real-time run
python liveplot/show.py
. - Run script
python test_agent.py
. To pause/unpause recording hitP
key.