This will work with other games too
Made by following tutorials by Sentdex
-
Tensorflow-gpu (pip install tensorflow-gpu) (tensorflow for cpu will work, but will take a much longer time, possibly days, to fit the model)
-
CUDA and CuDNN that are compatible with each other and the tensorflow version.
-
mss for screen-cap (pip install mss)
-
numpy (pip install numpy)
-
opencv (pip install opencv-python)
(Save yourself some time and do
pip install -r requirements.txt
)
Change the game resolution to 800x600. If you want to use a custom resolution, edit monitor dict in trainingdatacollector.py.
Position the game window in the top left corner, make sure no other window is overlapping with the game window.
Start trainingdatacollector.py and play the game yourself in the manner you want the Neural Net to learn.
If you want to register extra keys while playing, edit the keys_to_output function. Change the size of the one hot array and add more statements accordingly
(consider automating the OHE conversion process if you have too many keys)
After collecting the training data, use balancedata.py to balance the data. You may need to edit balancedata.py if you have additional keys.
Anything less than 50k samples, post-balancing, will yield poor results. Try to reach at least a 100k samples, post-balancing
Use modelfit.py to fit everything, make sure alexnet.py is in the same directory. (you may need to edit alexnet.py if you have additional keys)
After saving the model, start up the game again, position it correctly and use testingfile.py
If all goes well then the ingame character should move according to the predicted moves made by the model you made.
clone https://github.com/tensorflow/models and move the .py file to models\research\object_detection
The bot is ridiculously slow, gives a shitty frame-rate and heats up your system. What more could you ask for? :)
(will update the bot to be faster and more accurate in the future)