Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Override player input with machine learning models #17407

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

MatPoliquin
Copy link

@MatPoliquin MatPoliquin commented Jan 13, 2025

This PR adds support for overriding player 1 and/or 2 controller input with custom AI.
For example, NHL94 Sega Genesis community wants to be able to play against better AI, this feature address their needs.
The AI/machine learning part is in an external library so that way there is no need to update RA code base every time there is changes made to a game's AI, updates to pytorch, changes in model format, etc

Users can toggle on/off overriding input with the "Game AI" section in the quick menu.

This is an experimental feature at an early stage and should be turned off by default
Only works on Windows and Linux for now (x86), but eventually more platforms will be supported

Question:
This feature needs an external lib that I made + data (models/ram info). Where is best to put the build instructions for this?
https://github.com/MatPoliquin/stable-retro-scripts/tree/main/ef_lib

game_ai_menu

@LibretroAdmin
Copy link
Contributor

Seems like the CI checks failed.

intl/msg_hash_us.c Outdated Show resolved Hide resolved
@MatPoliquin
Copy link
Author

Seems like the CI checks failed.

Fixed

@MatPoliquin MatPoliquin marked this pull request as ready for review January 14, 2025 07:10
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
ai/game_ai.cpp Outdated Show resolved Hide resolved
configuration.c Outdated Show resolved Hide resolved
runloop.c Outdated Show resolved Hide resolved
@viachaslavic
Copy link
Contributor

As far as I understand it requires a manually launching separate instance from https://github.com/MatPoliquin/stable-retro-scripts? This may not be very user-friendly. Maybe it makes sense to make it as a dynamic library or run/control the subprocess directly from RA?

@MatPoliquin
Copy link
Author

As far as I understand it requires a manually launching separate instance from https://github.com/MatPoliquin/stable-retro-scripts? This may not be very user-friendly. Maybe it makes sense to make it as a dynamic library or run/control the subprocess directly from RA?

It's already a dynamic lib, only this part of the stable-retro-scripts repo is used with retroarch (ef_lib folder):
https://github.com/MatPoliquin/stable-retro-scripts/tree/main/ef_lib

The python scripts you see are used to train and test the models shipped with the lib

@viachaslavic
Copy link
Contributor

viachaslavic commented Jan 14, 2025

It's already a dynamic lib, only this part of the stable-retro-scripts repo is used with retroarch (ef_lib folder): https://github.com/MatPoliquin/stable-retro-scripts/tree/main/ef_lib

Perhaps it makes sense to place it in deps folder? (excluding the models, which will apparently be able to be added downloads in the future via the online updater)

@MatPoliquin
Copy link
Author

MatPoliquin commented Jan 14, 2025

It's already a dynamic lib, only this part of the stable-retro-scripts repo is used with retroarch (ef_lib folder): https://github.com/MatPoliquin/stable-retro-scripts/tree/main/ef_lib

Perhaps it makes sense to place it in deps folder? (excluding the models, apparently)

Added the ef_lib folder (named it game_ai_lib) in deps

@MatPoliquin
Copy link
Author

It's already a dynamic lib, only this part of the stable-retro-scripts repo is used with retroarch (ef_lib folder): https://github.com/MatPoliquin/stable-retro-scripts/tree/main/ef_lib

Perhaps it makes sense to place it in deps folder? (excluding the models, which will apparently be able to be added downloads in the future via the online updater)

Just saw your edit about online updater downloading the models... that would be very cool!

ai/game_ai.cpp Outdated
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;

hinstLib = LoadLibrary(TEXT("game_ai.dll"));
assert(hinstLib);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retro_assert here and below

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants