Improving the AI in aethermancer
I've been looking for a challenge in Aethermancer. Only level 5 AI provides me that challenge, but with turns occasionally taking 50s, the wait time seems excessive.
Brief recap on how the AI works:
There's a base ai() function. It takes a game state, simulates all possible moves, and goes for the one with the best eval.
Level 1: ai(), but selects a card at random and must play that.
Level 2: ai(), but then adds a random factor to each eval
Level 3: ai()
Level 4: For all possible moves, simulate the game. Then run ai() on this, and optimize against it.
(This internally referred to as visionary.)
Level 5: For all possible cards you have, run visionary() to decide what lane you would play it in, if you were to play it. Then, out of this reduced pool of moves, simulate the game, run visionary(), and optimize against this.
Part of the reason why the AI takes so long as all of the simulations it runs - with each simulation it makes it must copy the game in order to not affect the original copy. Our game class does have a custom __copy__() method to not copy more than it needs, but still, all these calls to copy are expensive.
However, I've been working hard to make the AI faster. What if we made less copy calls? The AI simulates every possible move, and if a move is illegal, the game raises an AssertionError, which the AI evaluates as -100000000000000 value. However, by adding code to detect if a move will be illegal ahead of time, we can run that code on the original game. If the move is illegal, then we do not need to simulate the game, saving an expensive call to copy().
With this optimization, the AI runs almost 2x faster!
After some feedback from more casual players, I have reworked the AI to allow for even lower difficulties. Under the new AI system
Level 2 (max): Same as visionary
Level 1: Same as tricky
Level 0: Same as challenging
Level -1: Same as easy
Infinite more negative levels exist, each one adding increasing amounts of noise to the AI decisions.
All of this is available in v0.6.1 of the game.
Get Aethermancer
Aethermancer
Status | In development |
Author | MasN3 |
Genre | Card Game |
Tags | Multiplayer |
Languages | English |
More posts
- v0.8.3 patch notes11 hours ago
- v0.8.2 patch notes22 hours ago
- The Roadmap for v0.71 day ago
- A change in the base set1 day ago
- Prototype pvp_main.exe2 days ago
- The Challenge of Balancing Vampires2 days ago
- Balancing Combinations in Aethermancer2 days ago
- Update v0.6.32 days ago
- Update v0.6.22 days ago
Leave a comment
Log in with itch.io to leave a comment.