The trex runner game is from wayou repo's in here. What I do here is just adding the setup for reinforcement learning.
This is my first time to build a reinforce learning project. Hope I can improve more, feel free to reproduce or modify the code.
Rakka Alhazimi, October 2021
First, let me tell you the summary of what I was use here
Software:
- Python v.3.7.7
- OS : Windows 10
Python side-libraries:
- Selenium
- Keyboard
- Tensorflow
- Numpy
Web-Driver for Selenium:
- Chrome
Any version is okay I guess, as long as the dependencies are fulfilled.
To make this project runs well on your machine, what you need to do is:
-
Install Python
After you install python, I suggest you to make an venv with command:
python -m venv [name]
it'll build a folder in your directory right away, and to activate the env use:
[name]\Scripts\activate.bat
Then install all the dependencies using:
pip install selenium, keyboard, tensorflow, numpy
You can jump right into installing the dependencies if you already have python and venv intact.
-
Install Chrome Web-browser
Chrome lets us to access console.log message from selenium. Therefore, Google Chrome is a must.
-
Download webdriver for chrome here
Match the driver with your Chrome version, after you download it, move the driver in your current directory (repo directory / same level with main.py).
-
Start your local server to serve
index.html
You can use live server from VS-Code or anything else. Then copy your localhost link likehttp://127.0.0.1:5500/
to theCONFIG
variable inutils/config.py
file. -
Start the program The main file is
main.py
, run this file to start the program.python main.py
You can update or change the settings and hyperparameter in the utils/config.py
file.
Hyperparameter that you must know:
SERVER
: Your local server link to be redirected by the webdriverTRAIN
: Whether or not you want to train the modelCONTINUE
: Whether or not you want to continue from the model checkpointsEPISODES
: The number of episodes you want to run
How do I train this dino agent:
- Go for
100 - 500 Episodes
with1e-2 Learning Rate
- Set the
max reward = 500.000
Regular policy gradient method
I try to make a reinforcement learning project with the in-game parameters. Other peoples are likely to snipe the screen pixel or taking multiple screenshot to gain the parameters of the state. Therefore, I would like to try different approach by peeking the game-code and get its variable. It's much faster and memory-friendly. The rest is still the same, the approach, model and etc.
I hope you can enjoy training your agent using the default model or you can also build your owns model to beat
this game, any modification is welcomed. You can also change how the parameters is recorded inside the src/js/watcher.js
file.