Mathieu Poliquin 66e23fca79
New feature: Override player input with machine learning models (#17407)
* Add dummy game ai subsystem

* First working prototype of a machine learning model that can override player input

* Update README.md

* Update README.md

* Fix loading path on Windows

* Change ai override to player 2

* Added quick menu show game ai option

* Implemented Quick Menu entry for Game AI options

* Redirect debug logs to retroarch log system + properly support player override

* Added support to use framebuffer as input to the AI

* Added pixel format parameter to API

* Fix game name

* code clean-up of game_ai.cpp

* Update README.md - Windows Build

* Update README.md

* Update README.md

* Update README.md

* Update config.params.sh

turn off GAME_AI feature by default

* Fix compile error in menu_displaylist.c

* Add missing #define in menu_cbs_title.c

* Added new game_ai entry in griffin_cpp

* Remove GAME_AI entry in  msg_hash_us.c

* Fix compile error in menu_displaylist.h

* Removed GAME AI references from README.md

* Fixes coding style + add GameAI lib API header

* Convert comment to legacy + remove unused code

* Additional coding style fixes to game_ai.cpp

* Fix identation issues in game_ai.cpp

* Removed some debug code in game_ai.cpp

* Add game_ai_lib in deps

* Replace assert with retro_assert

* Update Makefile.common

* Converting game_ai from cpp to c. First step.

* Convert game_ai from CPP to C. STEP 2: add C function calls

* Convert game_ai from CPP to C. Final Step

* Added shutdown function for game ai lib

* Update game_ai_lib README

* Fix crash when loading/unloading multiple games
2025-01-21 13:05:43 +01:00
..

stable-retro lib

Library to be used with emulator frontends (such as RetroArch) to enable ML models to overide player input. Warning: Still in early prototype version

Build for Linux

sudo apt update
sudo apt install git cmake unzip libqt5opengl5-dev qtbase5-dev zlib1g-dev python3 python3-pip build-essential libopencv-dev
git clone https://github.com/MatPoliquin/stable-retro-scripts.git

Download pytorch C++ lib:

cd stable-retro-scripts/ef_lib/
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.1%2Bcpu.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.3.1+cpu.zip

Generate makefiles and compile

cmake . -DCMAKE_PREFIX_PATH=./libtorch
make

Build for Windows

Clone stable-retro-scripts repo

Download pytorch C++ lib for Windows:

wget https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.3.1%2Bcpu.zip -o libtorch_win.zip
Expand-Archive libtorch_win.zip

Note: 2.3.1 might have missing intel MLK dll issue: https://github.com/pytorch/pytorch/issues/124009 So you can use nightly build instead and it fixes the issue: wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-win-shared-with-deps-latest.zip -o libtorch_win.zip

Download and Extract OpenCV for Windows:

https://sourceforge.net/projects/opencvlibrary/files/4.10.0/

The DLLs will be found here: YourOpenCVFolder\opencv\build\x64\vc16\lib

Generate makefiles and compile

cd stable-retro-scripts
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=Absolute\path\to\libtorch_win -DOpenCV_DIR=Absolute\path\to\opencv\build\x64\vc16\lib
cmake --build . --config Release

Test the lib

export LD_LIBRARY_PATH=/path/to/game_ai.so
./retroarch