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.pychangeDATASET_FOLDERto output folder. Also changeSCREEN_REGIONto 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 hitPkey. - 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_PATHto path of recorded npy frames andOUTPUT_FOLDER_PATHto output path.
Check OD_training folder.
- In
AE_create_dataset.pychangeINPUT_DIRto path to your collected dataset folder. AndOUTPUT_DIRto output folder. - Create dataset for Autoencoder using
python AE_create_dataset.py. - In
AE_training.pychangedataset_dirto 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.pychangeDATASET_PATHto path to dataset. Dataset must be in particular format. Root folder must containEXPERTandBASICfolders. 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_PATHto output directory. - In
SL_create_dataset.pychangeOD_initto full path tologdir/ODif needed. Also changeAE_inittologdir/AE/{any_params}/saved_model/model.ckptif needed. - Create dataset using
python SL_create_dataset.py - In
SL_training.pychangedatasets_pathto dataset path containingEXPERT.npyandBASIC.npy(output of 3rd step). To continue training changeinit_model_pathto 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
logdirfolder with folder inside downloaded zip file.
- In
test_agent.pychangeOD_initto frozen_graph folderlogdir/OD. Also changeAE_initandSL_initto 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 hitPkey.