AI Players static registration for debug menu and cleanup #8492
Closed
trevan
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is for discussing two possible "static registrars". One for the debug menu and one for AI cleanup.
Debug Menu
Currently, there is code in
DebugMenu
that checks if any of the players are of typeAbstractProAi
. And if there is, it will then callAbstractProAi.initialize
and add a menu option.I'd like to add a
DebugMenuRegistry
that has aMap<String, Collection<Function<TripleAFrame, Collection<JMenuItem>>>
. Callers would register their debug menu by specifying the name of the menu and the callback that will build the items in the menu. WhenDebugMenu
is instantiated, it would have the map passed into it and it would construct the debug menu using that data.AbstractProAi
would then add code to itsinitialize
to register its menu item.Cleanup
Currently, the ProAI has a static
gameOverClearCache
method that is run at various points ofgame-core
when the system is shutting down. I looked into moving the code intoProAi#stopGame
but there are a few edge cases wherestopGame
isn't called butgameOverClearCache
is (such as when an exception is thrown during a game or when the game is shutdown).I'd like to allow my AI (and others) to hook into the same
gameOverClearCache
without needing to editgame-core
. My thinking is to add aGameOverRegistry
that has static methods for adding new callbacks (with a type similar toRunnable
- no parameters, void return type). All the places that currently callProAi#gameOverClearCache
would be updated to instead grab the list of callbacks fromGameOverRegistry
and call them. The ai players would then be able to register their cleanup callbacks duringinitialize
.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions