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

Partial Python rewrite #361

Closed
taylorhansen opened this issue May 9, 2023 · 2 comments
Closed

Partial Python rewrite #361

taylorhansen opened this issue May 9, 2023 · 2 comments
Assignees
Labels
ai Has to do with the AI enhancement Something should be changed training Has to do with the training script

Comments

@taylorhansen
Copy link
Owner

taylorhansen commented May 9, 2023

With the growing complexity of the RL/ML side of this project, the training code is starting to hit the limits of the current TFJS/Node capabilities, having to re-implement some frameworks/algorithms from scratch (training loop, attention layers, etc) and hitting bugs and performance issues. Part of this project will be rewritten in Python in order to better take advantage of deep learning libraries and resources.

Since the simulator used by this project is written in JavaScript, inevitably part of code will have to remain in that language, while connecting it to the main Python training script (or inference server in PsBot workflow) via an interop library. After some iteration the best place to draw the JS-Python barrier seems to be at the BattleAgent level, where a JSON describing the battle state can be sent to Python to calculate inferences, do ML, etc. and then send action responses back. Most of the PsBot and BattleState modules will remain unchanged and can still take full advantage of the modular PS libraries that are currently being used, while inference and training code will be rewritten in Python and further features/improvements built on top of that.

@taylorhansen taylorhansen added enhancement Something should be changed ai Has to do with the AI training Has to do with the training script labels May 9, 2023
@taylorhansen taylorhansen self-assigned this May 9, 2023
@scheibo
Copy link

scheibo commented May 21, 2023

Since the simulator used by this project is written in JavaScript, inevitably part of code will have to remain in that language, while connecting it to the main Python training script (or inference server in PsBot workflow) via an interop library

I'm not sure about the scope this project is interested in (Gen 4? All gens?), but https://github.com/pkmn/engine (which has a Python driver, https://github.com/AnnikaCodes/PyKMN) is a more accurate and much faster engine for Gen 1 (and aims to eventually support further old gens) and may be worth considering.

@taylorhansen
Copy link
Owner Author

Thanks for bringing this to my attention!

Currently only Gen 4 Random Battles are being supported for now since it's simple enough but not too far removed from modern gen mechanics so that once I confirm a good ML algorithm and a stable underlying framework I can start writing Gen 5-9 and/or doubles versions. It seems that this libpkmn only supports Gen 1 so I can't use it right now, but once it's more fully featured for higher gens I'd be interested in switching out @pkmn/sim for it to try and speed up model training.

Thanks for telling me about this library and I'll keep watch for new updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai Has to do with the AI enhancement Something should be changed training Has to do with the training script
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants