Magarena AI
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Magarena AI
by ubeefx » 12 Dec 2010, 17:29
The project page now contains a Wiki page with a detailed description of the Magarena AI.
You can discuss it here. Also when you find any strange behavior of the AI, please describe it here.
You can discuss it here. Also when you find any strange behavior of the AI, please describe it here.
Re: Magarena AI
by telengard » 12 Dec 2010, 19:37
Nice writeup!
I do a lot of the same things in my application (an undo engine for backing out changes, eval function with tweaks based on phases/etc, multi-threaded AI on copies of game state, minmax w/ smarts for phases etc, memory pool per game state at each depth to allow high depths without running out of memory).
One thing that really intrigued me, and at one point I had considered doing was your "score caching". I've seen this sorta thing done in Chess AIs too (transposition tables). How on earth did you get this to work with the amount of game state data there is for a game like Magic? In my engine I could not come up with a way to have all of the current state data map to a single identifier. I support all pieces/rules/abilities in my game so there is a lot to keep track of (assigned damage/venom, destroyed/disrupted pieces, piece locations, various "pools", sustained effects, engine hooks (for abilities), whether pieces have moved/attacked, etc etc).
I know something like this would REALLY speed up my engine because a lot of the time, the same set of actions done in a different order end up with the same game state/result and I could prune better in those cases.
~telengard
I do a lot of the same things in my application (an undo engine for backing out changes, eval function with tweaks based on phases/etc, multi-threaded AI on copies of game state, minmax w/ smarts for phases etc, memory pool per game state at each depth to allow high depths without running out of memory).
One thing that really intrigued me, and at one point I had considered doing was your "score caching". I've seen this sorta thing done in Chess AIs too (transposition tables). How on earth did you get this to work with the amount of game state data there is for a game like Magic? In my engine I could not come up with a way to have all of the current state data map to a single identifier. I support all pieces/rules/abilities in my game so there is a lot to keep track of (assigned damage/venom, destroyed/disrupted pieces, piece locations, various "pools", sustained effects, engine hooks (for abilities), whether pieces have moved/attacked, etc etc).
I know something like this would REALLY speed up my engine because a lot of the time, the same set of actions done in a different order end up with the same game state/result and I could prune better in those cases.
~telengard
Author of Dreamblade:
viewtopic.php?f=51&t=1215
viewtopic.php?f=51&t=1215
-
telengard - DEVELOPER
- Posts: 379
- Joined: 23 May 2009, 23:04
- Has thanked: 2 times
- Been thanked: 27 times
Re: Magarena AI
by ubeefx » 12 Dec 2010, 21:46
Thanks.
About the score caching, what I try to do is create some kind of a hash code of the game state.
Although a lot of the state is used, it does not use everything. Also the more complex the state becomes,
like adding player poison counters, the more different game states will map to the same code.
The code could for instance then become 2 times 64 bits, or even more, but there will always be cases where it does not work correctly.
However I did some testing and this seems to work quite well most of the time.
One thing that is used to calculate the identifier next to the game state is the score at that time, because it also tells a lot about what happened.
About the score caching, what I try to do is create some kind of a hash code of the game state.
Although a lot of the state is used, it does not use everything. Also the more complex the state becomes,
like adding player poison counters, the more different game states will map to the same code.
The code could for instance then become 2 times 64 bits, or even more, but there will always be cases where it does not work correctly.
However I did some testing and this seems to work quite well most of the time.
One thing that is used to calculate the identifier next to the game state is the score at that time, because it also tells a lot about what happened.
Re: Magarena AI
by mtgrares » 15 Dec 2010, 19:09
Your Wiki AI page was very detailed, I won't say that I understood all of it but I enjoyed reading it. Thanks for such a thorough explanation.
I was curious to see if your AI looked at the players hand or library and the answer is no. There isn't a right answer, I was just wondering.
Last night I had a great 39 turn game against the Magarena where I came back to win from AI - 46 life, me - 16 life. Of course drawing Akroma, Angel of Wrath and Venser, Shaper Savant didn't hurt.
I was curious to see if your AI looked at the players hand or library and the answer is no. There isn't a right answer, I was just wondering.
Last night I had a great 39 turn game against the Magarena where I came back to win from AI - 46 life, me - 16 life. Of course drawing Akroma, Angel of Wrath and Venser, Shaper Savant didn't hurt.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: Magarena AI
by ubeefx » 15 Dec 2010, 23:52
Putting all the detail into the page actually helped me get a full picture again how the AI works.
The sometimes very close or long games with the AI are indeed fun.
Life gain can be really strong in Magarena in some situations.
The sometimes very close or long games with the AI are indeed fun.
Life gain can be really strong in Magarena in some situations.
Re: Magarena AI
by Happy Cat » 28 Dec 2010, 06:08
Played last evening. AI did well for the most part but it surprised me by destroying unequiped Leonin Scimitar instead of unequiped Sword of Body and Mind using Trygon Predator.
- Happy Cat
- Posts: 26
- Joined: 03 Aug 2009, 06:16
- Has thanked: 0 time
- Been thanked: 0 time
Re: Magarena AI
by Huggybaby » 28 Dec 2010, 13:17
I've noticed also that the AI is not afraid to attack with two guys when it knows one of them is going to get creamed. This is in direct contrast to the new DotP AI, which will never attack unless it's perfectly safe to do so.
-
Huggybaby - Administrator
- Posts: 3207
- Joined: 15 Jan 2006, 19:44
- Location: Finally out of Atlanta
- Has thanked: 701 times
- Been thanked: 594 times
Re: Magarena AI
by Aswan jaguar » 06 Apr 2011, 16:16
Is this just my wild imagination or you have implement a mock feature in AI.This is what happened in 2,3 games that AI had superior forces both in numbers and power and I was no threat.It could win me in a strike but instead it attacked only with 1 creature that I blocked and lose mine ,next turn the same again attacked only with 1 creature that I blocked and lose mine as if it was mocking me,and wanted to ridicule me.
*Does AI know what cards I have in my deck?
*Does AI know what cards I have in my deck?
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8078
- Joined: 13 May 2010, 12:17
- Has thanked: 730 times
- Been thanked: 458 times
Re: Magarena AI
by ubeefx » 06 Apr 2011, 20:15
The AI does not know or try to find out what cards are in your library or hand for the moment.
But it does try to win with the highest score.
On level 6 that is the highest score after 3 turns (6 main phases).
So that could be the reason why the AI postpones the victory, to increase the score.
But it does try to win with the highest score.
On level 6 that is the highest score after 3 turns (6 main phases).
So that could be the reason why the AI postpones the victory, to increase the score.
Re: Magarena AI
by MageKing17 » 09 Apr 2011, 21:02
Why is a postponed victory worth more? Winning as quickly as possible should be worth the most to it.ubeefx wrote:The AI does not know or try to find out what cards are in your library or hand for the moment.
But it does try to win with the highest score.
On level 6 that is the highest score after 3 turns (6 main phases).
So that could be the reason why the AI postpones the victory, to increase the score.
-
MageKing17 - Programmer
- Posts: 473
- Joined: 12 Jun 2008, 20:40
- Has thanked: 5 times
- Been thanked: 9 times
Re: Magarena AI
by ubeefx » 10 Apr 2011, 21:48
Actually the scoring does take earlier wins into account.
But maybe in this case the "extra gain" for the AI overshadows it.
But maybe in this case the "extra gain" for the AI overshadows it.
Re: Magarena AI
by Aswan jaguar » 21 Apr 2011, 18:45
You say that AI won't make a bluff but I can't explain (especially with Magarena great AI) the reason AI will attack with 2/2 creature into a 3/3 one when it is not obliged to do so (attack each turn) and doesn't have an istant to boost it?Next time I will make a video or photo to back it up.
* Is it possible that bigger card pool and AI changes to have made AI in certain scenarios not to make the best possible moves.
* What is your evaluation of AI in order of difficulty?
DEFAULT
MINIMAX
MONTE CARLO
VEGAS
RANDOM=the weakest I guess.
* Is it possible that bigger card pool and AI changes to have made AI in certain scenarios not to make the best possible moves.
* What is your evaluation of AI in order of difficulty?
DEFAULT
MINIMAX
MONTE CARLO
VEGAS
RANDOM=the weakest I guess.
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8078
- Joined: 13 May 2010, 12:17
- Has thanked: 730 times
- Been thanked: 458 times
Re: Magarena AI
by ubeefx » 21 Apr 2011, 19:19
The Monte Carlo AI is the hardest to compare, because it uses the normally hidden information about hand and library of opponent.
So that should make it more challenging in the cases where this is beneficial.
It should be better than Vegas and sometimes MiniMax.
All other AIs do not know about hidden information. They were not explicitly learned to bluff.
- Default or MiniMax at level 6 is currently optimal
- Vegas at level 8 is worse and non deterministic, but has consistent speed and could be fun due to more random play
- Random is as implied just bad, but it will still use some features like the legal target filtering
Now let me be clear about this, the AI will not always make the best move guaranteed.
The scoring system and caching are good but not perfect.
So that should make it more challenging in the cases where this is beneficial.
It should be better than Vegas and sometimes MiniMax.
All other AIs do not know about hidden information. They were not explicitly learned to bluff.
- Default or MiniMax at level 6 is currently optimal
- Vegas at level 8 is worse and non deterministic, but has consistent speed and could be fun due to more random play
- Random is as implied just bad, but it will still use some features like the legal target filtering
Now let me be clear about this, the AI will not always make the best move guaranteed.
The scoring system and caching are good but not perfect.
Re: Magarena AI
by Aswan jaguar » 22 Apr 2011, 07:31
Will reports of AI's worse moments or tactics help you improve it further?If it is helpful I will be glad to report such cases,while I have so much fun and challenging games to play.
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8078
- Joined: 13 May 2010, 12:17
- Has thanked: 730 times
- Been thanked: 458 times
Re: Magarena AI
by ubeefx » 22 Apr 2011, 18:03
If there would be an option to save a replay for a game, then these could be shared.
I am thinking about making a new Limited Edition with this option.
Then it will be easier for me if I have a number of these replays to find improvements.
Might also add the right mouse click action and some cool cards from New Phyrexia.
I am thinking about making a new Limited Edition with this option.
Then it will be easier for me if I have a number of these replays to find improvements.
Might also add the right mouse click action and some cool cards from New Phyrexia.
15 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 22 guests