Custom AIs: brainstorming thread

Discussion of hacking, editing and developments in Advance Wars games.
Remember, no Rom Requests
rorosaurus

Custom AIs: brainstorming thread

Post by rorosaurus » Wed May 17, 2017 10:00 am

Hi all,

I've been wanting to tackle this project for a while now. Custom AIs in AW2. I'm still at the brainstorming stage. This would be my first venture into ROM hacking, but I'm comfortable with ASM and writing APIs.

That said, I'd love to hear any initial feedback or tips you might have for the high-level approach. I envision it unfolding something like this:
  1. Reverse engineer the default AI ASM to learn how it works (and document it)
  2. Modify or redesign the default AI ASM in-place. (Maybe it would be fairly easy for lengthy AI modifications to jump to ROM addresses outside the standard ROM space to prevent overwriting other ASM and risk breaking the game? Not sure, I'll have to tinker and learn!)
  3. Develop and expose some simple API for writing AW2 AI's in a higher-level language. (Perhaps a nice way to interact with a LUA script via certain emulators? Or something more dirty and hacky?) Imagine making AI development easy enough for anyone! What's more fun than PvP? Player's AI vs. Player's AI. :wink:
  4. Train a custom evolutionary AI. Fight the default AI and previous evo AI iterations on an emulator at super speed continuously. Train generations and generations and breed the most successful AIs. Once it's half-decent, intermittently fight against human opponents and weight those games heavier than vs. AI training matches. Once I'm happy, reduce it to ASM and cram it into a IPS to distribute :)
It seems like Xenesis already tinkered with it a bit, of course. I'll have to start my investigation around those addresses.

More whacky ideas:
  • A neural net might be fun, too. But only for a very specific case. Maybe Spann Island could be an interesting, limited-scope experiment.
  • Maybe I can crunch data from AWBW games to reduce universal patterns directly to AI tactics.
Thoughts?

User avatar
Xenesis
Tri-Star CO
Tri-Star CO
Rank: Hydrocarbon Inspector
3DS Code: 2535-4646-7163
Location: 0x020232DD

Re: Custom AIs: brainstorming thread

Post by Xenesis » Thu May 18, 2017 4:27 pm

Hah, I'd really like to see this. I (obviously!) have an interest but it's a huge scope type project.

I've certainly got a lot documented and not all of it is on WWN, some of it's just sort of appeared in other spots as I've looked into it and worked on stuff. It's pretty much all trigger-response type stuff, but it's fairly complex and ties into a tonne of the other subsystems in the game. What always made it more difficult to research was the fact there's different attributes assigned to each CO and also for various things like War Room or Campaign maps.
rorosaurus wrote:
Wed May 17, 2017 10:00 am
Maybe it would be fairly easy for lengthy AI modifications to jump to ROM addresses outside the standard ROM space to prevent overwriting other ASM and risk breaking the game? Not sure, I'll have to tinker and learn!
This should be quite trivial to do if you want to add more functionality to subroutines! The GBA is fully memory mapped in a 32-bit address space, including the entire ROM image. Adding more code is as simple as writing a short hook function and getting it to jump to new code. AW2 uses ~6.7 MB of the nominal 8 MB cartridge it was on, but the GBA supports 32 MB cartridges without any expansion so it's relatively simple to port, duplicate or move code if you're comfortable with assembly.

Of course, if you've got any questions pretty much shoot something off to me and I'll reply when I can...I enjoy talking about hacking stuff :lol:
IST wrote:Even the worst individual needs to discover the joys of a chicken statue that is also a pregnant blonde housewife.

rorosaurus

Re: Custom AIs: brainstorming thread

Post by rorosaurus » Tue May 23, 2017 3:26 am

Xenesis wrote:
Thu May 18, 2017 4:27 pm
What always made it more difficult to research was the fact there's different attributes assigned to each CO and also for various things like War Room or Campaign maps.
Yeah, I've been giving that some thought. I'm looking forward to seeing how the stock AI handles these things, but I think based on my personal experiences I don't really expect that much. For my evolutionary AI it makes sense that I would need to train a separate strategy for each CO to truly maximize it's potential. The same is true for maps, to a degree. And opponents (if I could even find a way to track that.) Or perhaps I could explicitly direct the AI to consider the CO/map/opponent information and weight it appropriately.

I think I could also reduce a lot of wasted training by creating my own game-state expander (or just using the emulator and save states to generate it). The evo AI could simply consider all combinations of legal moves for each turn. If I figure that out, I'd also want to program my own minimax AI that expands the game state to explore all possible paths within a certain time limit. I'd like to give my AIs some persistent storage so they can eventually generate or utilize some dictionary of opening moves for a certain map/CO/etc.

Thanks for the memory mapping info, I'm excited to dive more into that when time permits! Do you have a repository of all your notes and information somewhere? I intend to track and document my findings on one or more github repos as I work through things. :)

User avatar
Xenesis
Tri-Star CO
Tri-Star CO
Rank: Hydrocarbon Inspector
3DS Code: 2535-4646-7163
Location: 0x020232DD

Re: Custom AIs: brainstorming thread

Post by Xenesis » Thu May 25, 2017 4:56 pm

rorosaurus wrote:
Tue May 23, 2017 3:26 am
Thanks for the memory mapping info, I'm excited to dive more into that when time permits! Do you have a repository of all your notes and information somewhere? I intend to track and document my findings on one or more github repos as I work through things. :)
Yeah, I maintain an active dropbox of my notes: https://forums.warsworldnews.com/viewto ... 11&t=10861

The AI table formats are near the end, along with a bunch of ROM offsets (for most anything I find/document).

Anything that doesn't make sense, just ask as the document has over a decade of learning/cruft as my knowledge and skills improved. :lol:
IST wrote:Even the worst individual needs to discover the joys of a chicken statue that is also a pregnant blonde housewife.

Who is online

Users browsing this forum: Kim Jong-un [Bot], Multivac [Bot] and 0 guests