Recommend
19 
 Thumb up
 Hide
9 Posts

Warhammer: Invasion» Forums » General

Subject: Solo AI that has worked for me rss

Your Tags: Add tags
Popular Tags: [View All]
Paul Hackman
United States
Champaign
Illinois
flag msg tools
Avatar
mbmbmbmbmb
In an attempt to relearn all the rules and card effects to Warhammer: Invasion before trying to teach it to someone new, I have developed a solo AI to play against. Currently I own two Core, Ulthuan, March of the Damned, and the Corruption Cycle, however, over half the test games were done with just one Core and March of the Damned. So it was fun enough to convince me to buy more cards and it doesn’t require much deckbuilding to work.

Goals
Human player should play as he/she would in a normal 2 player game
AI should act basically how a real opponent would
AI should have some small advantages to compensate for being an AI
Minimal chart checking and dice rolling during AI turns

AI
1) Collect resources as normal during Kingdom phase.
2) During the Quest phase, advance any active quests as normal. Then calculate the total power in the zone. This is the number of “passes” that the AI has for the Capital phase.
3) During the Capital phase, draw cards from the top of the deck one at a time. If the robot can afford the card and use its power (no paying for tactics that have no effect or attachments that can’t be attached) then it pays the cost, using the normal loyalty discount. If the robot cannot afford the card then place it aside (not in the discard) as a “pass.” Continue buying cards until all the money is spent. If the AI uses all its passes, then the next card it draws that it cannot afford will end the purchasing part of the Capital phase even if there are resources remaining.
4) Once the AI is done purchasing cards, flip the next card from the top of the deck. If it has a cost of 2 or less, place it as a development. If the cost is more than 2, then put it back.
5) Put the “passed” cards back on top of the deck and reshuffle the draw deck.
6) Check cards for any optional Actions. If the Action would have any positive effect then flip a coin (roll a die) to see if the Action executes.
7) If there are any zones that can be damaged by an attack then execute the Battlefield phase as normal.
8) At the end of the human player’s turn, the robot does not reset its resources. Unused resources carry over between rounds.

So that’s the basic game play for the AI. I think it ends up working pretty much the way a normal game would play. The major change is that instead of drawing more cards by putting more power in the Quest zone, the AI simply gives itself more chances of drawing a card it can play, which, I think, roughly simulates the same idea. Not resetting resources makes the AI play a little different from a human (since it can, theoretically, place an expensive card very early in the game that its economy would normally not support) but this change is meant to simulate foresight by the player and to make the AI more challenging. Certainly you could make the AI reset its resources as well and it would still work.

Unit/Support Placement during Capital Phase
1) If the unit/support can perform an action only in a certain zone, place it in that zone
2) If there is an open quest, place an eligible unit on it
3) If no unit/support has been placed in the Kingdom this turn, place the unit/support in the Kingdom. If a unit/support has already been placed in the Kingdom, but not in the Battlefield, place the unit in the Battlefield. If a unit/support has already been placed in both the Kingdom and Battlefield, but not the Quest, place it in the Quest.
4) If each zone has already added at least one card this turn, place all remaining support cards in the Kingdom and place all remaining unit cards in either the Battlefield or Kingdom, whichever has less power on its current cards.

This is pretty simple even if it looks a little convoluted when written out. If a card has the name of a zone on it then it will always go to that zone. All other cards are free agents. With free agent cards the Kingdom has preference, followed by the Battlefield, and then the Quest zone, but I try to always give each zone one card before another zone gets a second or third. Support cards never go to the Battlefield unless they have text that says they should. The only time the Quest zone gets preference is if there is an open quest. This all works out because the AI doesn’t have to worry as much about drawing cards. So it focuses on building its economy and army. The Quest zone is, therefore, usually an easy target for the human player but going there for easy damage early in the game means allowing the AI to build up a powerful economic engine.

Development Placement
If the AI draws a card that is eligible to be placed as a development (cost of 0,1, or 2) then it is simply placed in the zone with the fewest hit points. In this case “hit points” includes the 8 hit points each zone starts with + any developments + any hit points on unit cards in the zone. In the case of a tie Quest>Battlefield>Kingdom. This means that the AI will use developments to shore up weakened zones. Early in the game most developments will go to the Quest zone, since it usually has the fewest units, so ignoring the Quest zone early means it will add several hit points before you finally attack it.

Actions
For most actions it should be obvious when during the turn they should be activated. Otherwise I try to execute all of them after the Capital phase and before the Battlefield phase. For each one I scan to see if it could possibly provide any positive benefit. So, for instance, the Orc card that can spend a resource to damage one of its own units will simply not be activated if there are no units on the field that currently benefit from damaged Orc units. If there is any potential benefit then I roll to see if it activates (Evens = yes, Odds = no). This seems like it could potentially take awhile, but in over a dozen games I don’t think I ever had more than one action to roll for in a single turn.

Battlefield Phase

The AI always attacks if it has units unless there are no zones it can attack and damage. I added this last part because of a game where I had enough damage cancellation cards that the Orcs couldn’t get any damage through if they continued to attack with one or two units at a time. If the combined power of the AI battlefield is enough to do at least one damage to a unit or capital, then the AI attacks. Normally, the target zone is chosen by random die roll. However, the AI never attacks an already burning zone. It also will always attack a particular zone if there is already one zone burning and the current power levels are enough to burn a second zone and win the game.

Assigning Damage
In combat the AI assigns damage in such a way to destroy as many units as possible. If it must choose between two units then it destroys the one that costs more. If they cost the same then roll a die. If there is not enough damage left to destroy another unit, place it all on the unit with the least hit points remaining. The same basic principles are used when dealing non-combat damage to target units. If it is possible to destroy a unit, do so. If it is not possible to destroy a unit, put the damage on the unit with the fewest hit points remaining. In case of a tie choose the unit that costs more. If still tied, choose by die roll.
However, for card effects that simply destroy a unit without dealing damage, the AI chooses the unit/support with the highest cost. If tied, then the one with the most remaining hit points. If still tied, roll a die.

Defending
When the human player attacks a zone, what does the AI do? It either defends with all units or with no units.
1) If the zone currently has no damage then the AI does not defend, unless the attack has enough power to burn the zone.
2) If the zone already has at least one damage then the AI defends with all units. Exception: units on quests never defend unless they are needed to prevent a zone from burning.
3) If defending with all units would still not be enough to prevent burning, then the AI does not defend.

Other actions basically follow the same principles:
Corrupting – when corrupting its own units, choose the ones with the fewest hit points; when corrupting opponents, choose the ones with the most hit points. Roll a die for ties.
Sacrificing – sacrifice the eligible unit with the lowest cost. If tied then the one with the fewest hit points. If still tied then roll a die.
Healing – Heal units with fewest remaining hit points. If tied then heal unit with higher cost. If still tied then roll a die.

So far I have played as the HE against Orcs, as the Empire against Orcs, as Orcs against the Empire, and as Chaos against the HE. I win about 1 out of 3, and probably 4 out of 5 games are very close and tense. These seem like good numbers for a solo game, but I am far from an expert player.

The one messy area is
Tactics
Many tactics cards are meant to be played at opportune moments from your hand to surprise your opponent. This is difficult to simulate in an AI that does not have a hand and cannot evaluate the tactical situation. In the core set there are plenty of tactics that simply deal damage or kill a unit. These are simple enough to integrate during the AI’s Capital phase. Just purchase them and execute them with the caveat that they will only be used if they damage the opponent more than the AI (so don’t use Troll Vomit to destroy all units if the AI is the only one with any units). Other Tactics are used during the Battlefield phase to add or subtract power. Originally, what I would do with these was place the resources needed to pay for them on the card and set it in the Battlefield. Then, during the Battlefield phase I would roll to see which zone the AI was attacking. If the AI attacked a zone where the Tactic card would be of use, I paid for it and used it. If not, then I returned the card to the draw pile and the resources to the AI’s bank.

Once I had enough cards to do a little more deckbuilding, however, I developed a new technique. I removed all the tactics for the race that could be useful during the Battlefield phase. For each race I was able to make a deck of about 12-16 such tactics. At the beginning of the game I take that deck of Battlefield Tactics and deal out 10 of the cards, face down, and put the rest out of the game. During the game, during each Battlefield phase I flip the top card of the deck after declaring attackers and defenders and see if the card would help the AI. The AI can pay for the card with leftover resources OR with power in its Quest zone. So if the AI has 2 power in its Quest zone and 1 leftover resource it can play any Tactic card that costs 3 or less. If the card does not apply to the current situation or would not help the AI then I put it aside, face up. Then I assign damage. Before applying damage, however, I flip one more card and see if it would change anything. Of course, if I have any Tactics cards in my hand I can respond just as in a normal game. Once a Tactic card is played it is removed from the game. The cards that get flipped but not played get reshuffled once the deck runs out. In this way I make attacking and defending a bit less mathematical since there is an unknown element. Twice, while attacking the High Elfs I was foiled by a well-placed Steel’s Bane. It’s extra shuffling and calculating, but it gives me a new reason to attack the AI’s Quest zone and captures some of that tactical battling from a real game. Even without it, though, I’ve enjoyed every solo game.

Deckbuilding
The human player can basically build a deck just as he would for a real opponent. There are a small number of cards that won’t work against the AI, mainly the ones that allow you to look at your opponent’s hand, but generally you can take your typical W:I deck and play it solo.

Building the AI decks takes a little planning. The biggest struggle will be working with cards that require a certain number of developments to trigger. The AI uses developments defensively and doesn’t consider anything else. It also will not turn an expensive card into a development even if doing so would be beneficial. Cards that increase hand size are worthless to the AI. Even with the separate Tactics deck, some Tactics remain too situational to be of use to the AI. Some Actions are just a bit too subtle or complex for the AI, but simpler ones work fine, though the more Actions in play the more die rolls and status checks.

I’m not certain you could make a 50 card AI deck for each race from just the Core set. However, I am certain you could make a functional and challenging Order deck and a functioning and challenging Destruction deck with a little mixing and matching from just the Core set. Just adding March of the Damned was enough for me to make mono-race AI decks for each of the four Core races.

Finally, I keep the rule that I lose once I deck out. However, the AI does not lose if it runs out of cards. Otherwise, first to burn two zones wins, though you could make the human player burn all three zones for an added challenge.
14 
 Thumb up
5.00
 tip
 Hide
  • [+] Dice rolls
Paul Hackman
United States
Champaign
Illinois
flag msg tools
Avatar
mbmbmbmbmb
Immediately after posting the rules for my AI I played two games against the High Elves. In both games the random draws for the AI were very poor as they started both games by spending all their resources on Tactics that dealt indirect damage, instead of developing their economy. Although I had to apply all the damage to my capital since I didn't have any units out, it still gave me time to get ahead in the economic race. In both games, however, I easily got the first two zones burning but hit a roadbump when going for the third and I actually was only one turn away from losing each game before getting the third burn. So even when the cards go your way, getting 3 burns before the AI gets 2 can be a challenge.

Then I played two games against a Dwarf deck and got utterly humiliated both times. In the two games I ended up doing a total of 1 damage to his capital. So just as I felt I was getting the hang of it with my deckbuilding the Dwarfs showed me how far I have to go.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Brett Austin
Japan
flag msg tools
badge
Avatar
mbmbmbmbmb
I am glad that you are exploring solo rules with this. I will have to give it a try at some point. Thanks!
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Paul Hackman
United States
Champaign
Illinois
flag msg tools
Avatar
mbmbmbmbmb
It looks really complex when written out, and maybe it will be hard to learn, but I speed through solo games now with little problem.

Still messing around with the Tactic rules. They have definitely added a lot to the game as I have been thwarted by well-timed tactics many times, but they also seem to be too easy to play for the AI. But too challenging is usually better than too easy with solo play.

If nothing else I've learned a lot about deckbuilding and card rulings from getting to play so much more.
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Paul Hackman
United States
Champaign
Illinois
flag msg tools
Avatar
mbmbmbmbmb
Played two epic battles against the Dwarfs. The solo play has really helped me tune my Chaos deck even if I would probably have to make a few more tweaks in order to play it against real opponents.

First battle I finally won against the Dwarfs. Usually I let the AI go first, but after being soundly defeated again and again by the Dwarfs I went first. This, combined with a slightly sluggish start for the Dwarfs, allowed me to get my corruption going. By the end I had just about every Unit corrupted on his side. So I won, but the victory was a bit hollow since the AI made obvious mistakes. For instance, I had a Den of Iniquity out which corrupted all units that entered undeveloped zones, but since the AI doesn't check for developments until the end of its Capital phase, I was able to get a lot of cheap corruptions. This has inspired me to check for developments with the first card draw instead of the last.

Another problem I encountered was that the AI kept piling up units in the Kingdom even though they had more money than they could ever need. So another slight tweak to the AI is that it no longer plays units to the Kingdom (unless they have special abilities that trigger there) once it reaches 10 resources.

In the second game I let the Dwarfs go first but they didn't get any great combos for a few turns which allowed me to get going. It looked like I was on my way to victory as I corrupted his only Battlefield unit and then attacked with a buffed Bloodthirster. I got the first burn on him, but he played Grudge Thrower Assault from the Tactics deck and destroyed my Bloodthirster and then it was downhill from there. Pretty sneaky for an AI.
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
K.Y. Wong
Singapore
Gardens by the Bay
flag msg tools
Avatar
mbmbmbmbmb
Thanks for your great effort on this.

Could you request an Admin to move this to Variants, it will be easier to locate for those looking for a solo variant.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Alex
United Kingdom
flag msg tools
badge
Avatar
mbmbmbmbmb
Excited to give this a try soon!!!
Thanks for the rules.
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Paul Hackman
United States
Champaign
Illinois
flag msg tools
Avatar
mbmbmbmbmb
BobSpoons wrote:
Excited to give this a try soon!!!
Thanks for the rules.


I have finally completed my W:I collection or at least close to it (I don't have three copies of all the first cycle cards). I'm moving to a bigger house so once I settle in I'm looking forward to building decks for every race and then honing the solo rules some more.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Alex
United Kingdom
flag msg tools
badge
Avatar
mbmbmbmbmb
pomomojo wrote:
BobSpoons wrote:
Excited to give this a try soon!!!
Thanks for the rules.


I have finally completed my W:I collection or at least close to it (I don't have three copies of all the first cycle cards). I'm moving to a bigger house so once I settle in I'm looking forward to building decks for every race and then honing the solo rules some more.


Great to hear
Looking forward to it thanks!!
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.