Min-Max Combat Code
 Posted: 21 Dec 2010, 19:48
Posted: 21 Dec 2010, 19:48I've started working on applying min-max to combat so the AI will attack and block better.  The code won't see any of the cards abilities so the AI will only see Royal Assassin as a 1/1 and Cemetery Reaper as a 2/2 with no abilities.  This limitation can be offset because min-max's evaluation function lets you assign a number value to each card.  Royal Assassin could be evaluated to be a 10 while a generic 1/1 with no abilities could be only 1.  
Of course creating a numerical value for all of Forge's 5,000+ cards is going to be challenging. I'll try to create a small helper app that will speed things along. And maybe cards should be evaluated from the player's perspective like the AI can only use cards in a limited fashion, so maybe Cemetery Reaper is a 8 from the human player's perspective and only a 5 from the AIs.
I'm hoping that the min-max combat code will be able use a few combat modifiers like: flying, wither, defender, and fear. More combat modifiers could be added later once everything is working. The code should be able to "see" several turns ahead and the code will not consider future creatures in the AI's hand.
I hope that I'm not stepping on anybody's toes. I haven't coded anything in awhile and I've been meaning to use min-max in some fashion. I would like to say that the code will be done by Christmas but I doubt it. It may be a few days later (although it is hard to guess). It seems like I'm 90% done because I only have to generate the possible combat situations. Of course if I get done and it doesn't work then I'm in big trouble.
I'm using actual commments and javadocs. If you just count the source code comments, any one class (in the new combat code) probably has more documentation that all of Forge's put together. I'm also using packages and so far I have 3.
Download (3.7 kb) This my progress so far.
p.s.
Technically I'm using the alpha-beta algorithm, which is an optimized version of min-max.
And in case I forget Merry Christmas.
			Of course creating a numerical value for all of Forge's 5,000+ cards is going to be challenging. I'll try to create a small helper app that will speed things along. And maybe cards should be evaluated from the player's perspective like the AI can only use cards in a limited fashion, so maybe Cemetery Reaper is a 8 from the human player's perspective and only a 5 from the AIs.
I'm hoping that the min-max combat code will be able use a few combat modifiers like: flying, wither, defender, and fear. More combat modifiers could be added later once everything is working. The code should be able to "see" several turns ahead and the code will not consider future creatures in the AI's hand.
I hope that I'm not stepping on anybody's toes. I haven't coded anything in awhile and I've been meaning to use min-max in some fashion. I would like to say that the code will be done by Christmas but I doubt it. It may be a few days later (although it is hard to guess). It seems like I'm 90% done because I only have to generate the possible combat situations. Of course if I get done and it doesn't work then I'm in big trouble.
I'm using actual commments and javadocs. If you just count the source code comments, any one class (in the new combat code) probably has more documentation that all of Forge's put together. I'm also using packages and so far I have 3.
Download (3.7 kb) This my progress so far.
p.s.
Technically I'm using the alpha-beta algorithm, which is an optimized version of min-max.
And in case I forget Merry Christmas.



