Tuesday, 26 May 2015

Impossible: AI

At some point in a tactics game you are gaming the computer player's decision making process instead of directly engaging. You know that the computer will always choose to move and attack if that is an option, so you can use a summoned unit just inside the movement range of an enemy unit to walk them back across the field. In theory if a unit has to move down one row and over three columns to get to you, they could go down that row at any point during their movement, but the computer will choose the point pretty consistently, so you can predict that and put a trap on the first hex they enter.

This isn't really showing tactical superiority so much as it is abusing the flaws of a predictable opponent. One of my favourite units is so good precisely because it is so good at abusing the AI.

Shamans are a pretty strange unit. As an orc unit they use the adrenaline system - whenever they attack or take damage they gain adrenaline that they spend to use their abilities. This is an issue for the shaman, a unit that is supposed to be standing back and casting totems rather than engaging in melee.

In a previous iteration, the shaman had an ability that gave it adrenaline whenever another orc unit gains adrenaline. That gave it some ability to use its totems and magical attacks but some rounds it couldn't. In Dark Side they gave the shaman a really bizarre adrenaline generation ability.

At the beginning of the shaman's turn the shaman has a chance to be restored to a full 100 adrenaline. The chance this happens is one hundred minus the shaman's current adrenaline as a percentage. If you are mathematically inclined then you are probably thinking you read that wrong right now. But no, if the shaman has 65 adrenaline then there is a 35 percent chance it will fill to 100 at the start of it's turn. If the shaman has 10 adrenaline then there is a 90 percent chance it will fill to 100.

That is even more bizarre when you find that two of their three abilities cost 25. Since that divides evenly into 100, I can always keep using them forever. The other costs 15, so after many failed rolls it is possible to end up at 10 and actually end up with a turn when you can't use any ability, but that's pretty unlikely. Even if I was trying my hardest I'd only manage to avoid having an ability to use it would take me almost 240 rounds to get one round off.

So shamans can basically just use their abilities however they want. One of the abilities deals damage to an enemy and heals allies, the other two make totems. The totem of life gives increased defense to allies and heals them each round, the totem of death reduces the speed of enemies and deals damage each round. These effects affect those within two hexes of the totem.

While both of those sound potentially useful, neither is necessarily fight winning. What makes both of the totem abilities very powerful, though, is the AI. The AI has a great fondness for attacking totems and seems to do so above all other options. A well placed totem can divert all melee units on the opposing side. Because the totem of death reduces speed by one, when it comes to speed two units, any number of units can be defeated by a single shaman.

There isn't much to say about this fight. Turn on yakety sax and watch some peasants foolishly chase totems to their death. Sure, those peasants might not have done terribly well even if they played smart, but it's still pretty great to be able to beat them all with just totems. If you are wondering why I cast poison skull instead of chaos missile in thsi fight, it's because there is a medal for many poison skull casts that will increase my maximum mana. Basically, I'm just increasing my cast count because I know the fight is already won.

Friday, 22 May 2015

Impossible: Impossible

When I first started playing on impossible difficulty it seemed to be literally impossible. That dwarf fight I posted last time probably didn't look all that bad - it's the elf fight that's the real problem.

A battlefield from the game, showing the beginning of the battle with the elven guardian of light.

The wolves in that picture aren't wolves but werewolves, as are the elves with the blade on their hands. Like vampires, they have two forms, also like vampires they regenerate and their fast form has four speed. You may guess from the image that the fairies out front have five speed and a high initiative. The archers suffer no damage penalty for shooting across the entire arena, and the fauns are a ranged unit that can cast sleep.

So this, like the dwarf fight, is a battle against a very stacked opponent, but this time the opponent has high speed than you and have excellent ranged units. But that's not all. Wolves, and werewolves in wolf form, have a howl ability.

Howl: Lets loose a long, terrifying howl, frightening all living enemies of level 1-2. These enemies have a 50% chance of being forced to skip their turn. Charges: 1/1

That sounds pretty bad. But let's look at the description of the effect that Howl actually places on my imps:

Fear: Units are filled with fright and don't obey orders. They are afraid to attack the enemies of a higher level than itself.

Not a perfect localization, I'm sure, but you get the idea. The feared creature doesn't have a 50% chance to miss it's next turn, it acts without your control, attacking enemies equal or lower level than itself. This effect lasts two rounds, and there are two stacks of werewolves, so you don't actually get to control any level 1-2 units you have for the first four rounds of combat.

Four rounds of not controlling your army against an army twice the strength with faster, higher ranged units than you have. You can forgive me for thinking this was unbeatable.

A huge part of the problem is the units you are stuck with. The shelter has a selection of six units to recruit. It has a level one and two orc unit: Goblins and Furious Goblins. It has two level two demons, since there are no level one demons: Imps and Scoffer Imps. It has a level one and a level two undead unit: Skeletal Archers and Zombies.

But wait, that last one isn't for sure. There are some things in King's Bounty - a lot of things, actually - that are random. While the shelter alway has the same Orc and Demon units, the undead army has two level one and two level two units. The choice between zombies and decaying zombies isn't a big one - you can see from the screen shot above I didn't recruit them anyway. But the difference between skeletons and skeletal archers is the difference between a fragile ranged unit and a fragile melee unit. Guess which one of those is about a five times as good.

Because undead are immune to fear, this is an even bigger difference. If you only get to control one unit, do you want it to be the one that basically stands there and hopes to get to fight at some point or the one that is shooting things down?

But that's not the only thing in King's Bounty that is random. When you begin playing, you get a quest.

So talk to Clarissa, get some experience, a couple of potions and a scroll of Frost Grasp. It's a breadcrumb quest to get you going on the story.

The thing is, I didn't recall having Frost Grasp. You start with Poison Skull, which has a huge damage range and inflicts poison. Frost Grasp has a more predictable damage range and inflicts freezing, which deals damage like poison does, but which also reduces speed. You can see how that's better, but I still didn't see winning.

I tried starting again and got the above quest. Here are a couple of others I saw:

So the spell you get is random, as is the amount of experience you get. That seems crazy to me. Especially since the spell choices appear to have a very wide range. Frost Grasp would be handy, Fire Arrow would be as well. Magic Shackles is a great spell, and Time Shift is downright broken, but neither will do anything in the early hard fights.

So I was restarting hoping to get Fire Arrow because it has the best damage to mana spent ratio in at level two, which is the best you can do for those fights. I would also have been even happier with Trap, which does more damage and ends an enemy unit's turn so long as you can successfully place it in their path.

But instead, I got Chaos Missile, which I had no idea was even an option.

Let's take a look at Poison Skull.

These are the damage numbers with fairly low intelligence, but everything scales by multiplication, so the relative power of the levels stays the same. So rank one is about 20 damage per mana, ranks two and three are both a little over 25 damage per mana with increasing chances to poison.

Now let's take a look at Chaos Missile:

Rank one the missiles to 5 per mana, then they do 5.5 per mana, then they do 5.33 per mana. But, also, the number of missiles goes up from 3 to 6 to 9. So actually the damage per mana is 15, then 33 then 48. Plus, since the cost scales up faster it does even more damage per round, which is important for getting rid of units before they are able to do serious damage to you. 300 damage is a lot more than 170, and when you are able to scale it up to level 3 it's a huge asset.

So my second attempt at impossible I not only a massively more powerful spell, I also got random experience rolls that allowed me to hit level 5 before fighting the elves, and I swear the stacks in the human army were just 15-20% smaller by chance as well. Impossible turned to quite possible.

I'm pretty confident that having gotten past the guardians of light and the fight following that the game won't actually be all that hard on impossible mode, and so far the game has been proving me right. Next time, the trick I used in the early game to get units that could win fights.

Thursday, 21 May 2015

Impossible: Vampires

The very early game of King's Bounty is pretty rough. Really, the biggest challenge of the game is probably beating the three "Guardians of Light" that appear right after you first meet the spirit of darkness. You are level 5, have access to only a small selection of troops, haven't been able to search for artifacts or spells, and don't yet have rage abilities.

These are very poor conditions to take on an army much larger than your own. One thing that helps a lot is that you start the game with two vampires.

When you start a battle, Vampires are in Vampire form, but they have the ability to change into bat mode. That doesn't take their action and they can continue their turn after transforming. Transforming clears negative status conditions and heals the vampires to full.

So you can choose between two speed and better combat stats or four speed and worse combat stats. But there is a lot of other text there. On the left side there is Regeneration, which heals the vampire to full at the beginning of each of its turns. That doesn't matter much in the late game when it is healing a few percent of their total health, but in the early game it lets vampires take on substantially more than they ought to be able to. On the right side there is Vampirism, which returns health to the vampire based on how much damage they do and can resurrect dead vampires.

But the most important text on each side is "No Retaliation." When a vampire attacks, the victim doesn't get to strike back. Because of that, and the speed of the bats, the two vampires you start with can beat out large numbers of slow moving units, which is awfully handy to get through at least the dwarf fight.

I haven't made much use of vampires, or even the improved version, Ancient Vampires, after those initial fights yet, but I always keep them in mind should a fight arise that requires some kind of extreme kiting.

A couple of notes about this fight: My leadership is just under 400 - Skeleton Archers are 13 each, Imps are 40. The enemy stacks average 890 leadership, so if this were zombie on zombie it would be my 13 against their 29, and that's with unfortunate rounding for them.

The dwarves move two, but have a one charge ability that lets them move an extra two, which is why they cross as much of the field as they do on the first round. The foreman - the dark bearded fellow - has an ability that makes the slowest dwarf unit on the field gain two speed and initiative for two turns. It gets the dwarf who runs down the right side. Because of that foreman ability I consider him to be the greatest threat, but at the same time he has very high initiative and uses the ability before I can stop him, so I work on the fast dwarves first before turning my attention to him to make sure he doesn't get a second activation. I don't manage to get the vampires in place fast enough to distract the second set of dwarves so I have to melee them a bit but it works out fine thanks to the no retaliation ability on imps. By round five the fight is essentially won - all the enemies are either not dead before their next turn or completely controlled. Between rounds 7 and 9 I do a very clumsy job of turning around, missing two attacks. On round twelve I finally drop the vampires out of bat form, confident that the miners can't do the required 70 damage in a single turn to beat them. I could have done that sooner, but was playing fast instead of doing math.

The furious goblins were basically brought in to soak damage, so losing just them was a result I was perfectly content with. The dwarf fight is the easy one, but on my last attempt to run impossible I'd lost my entire army aside from the vampires to it. I'll explain why next time.

Tuesday, 19 May 2015

Impossible: Why It's Not Impossible

Last Post I talked about why Impossible difficulty is so hard in King's Bounty. If two armies walk to the middle of the arena and fight it out then the one with five times the strength of the other is going to win. I'd say they have a high probability of winning, but it's a little beyond probability. If I'm a master tactician and manage to get my five stacks of guys to all attack one of their stacks while their other four stacks linger in the back, I still lose brutally.

So why is Impossible not literally impossible? There are several reasons:

Attack and Defense
Last time I simplified creature combat to ignore attack and defense, but you can't actually ignore those things. Each unit has an attack and a defense score. If the attacker's attack is higher than the defender's defense then damage is multiplied by 1 + (difference / 30) to a maximum of 3. If defense is higher then damage is divided instead.

For example, a black dragon has 2500 leadership, 1000 health and hits for 110-130. Peasants have 5 leadership, 6 health and hit for 1-2. If you put 500 peasants together to get 2500 leadership then you have 3000 health and 500-1000 damage. That doesn't make dragons sound good. But a dragon has 70 attack and defense and the peasants have only 1, so the dragon actually does triple damage to the peasants and takes only one third. Now that's still not great and the dragon loses in a stand up fight, on average about 840 peasants survive the fight - peasants are actually the second strongest unit I've found in terms of raw fighting power per leadership.

What helps you the player is that your hero has attack and defense scores that are added to all of your troops. These are affected by your skills and by your equipment. So when you start you get a weapon with +1 attack, giving your troops an average of a 3.3% damage edge over enemy troops of the same kind. Late in the game you might, depending on your class, have attack and defense scores ranging from 15 to 30 or even 40. Add 30 attack and defense to your 10 zombies from last time and they beat the 17 zombies with 6 of your zombies remaining. That's an extreme example, but even 5 points of attack and defense effectively scale that 70% army difference down to a 45% difference, which is a lot more manageable.

You can cast one spell every round, limited by your mana. If you start as the vampire you begin with both Slow, which reduces one unit's speed by 1 for 2 rounds for 5 mana, and Poison Skull, which does 45-155 damage for 5 mana and has a 30% chance of poisoning the target.

Back to those zombies, if you can do 100 spell damage to the enemy stack every turn of the fight then your zombies win with 5 zombies left.

That's better and worse than it sounds. It's better because you can be doing that damage before your zombies even meet their zombies. In fact, with low speed units like zombies you can probably spend your entire mana bar blasting them before you ever have to fight them in melee. Similarly, spells can target ranged units without actually having to get next to hem. Plus, while damage spells are nice, spells like Slow can control a battlefield and keep an enemy unit out of the fight for a long time.

On the other hand, it's not your 10 zombies against their 17. It's more like your 10 zombies times five vs. their 17 times five. Now you have run out your entire mana bar and you haven't even killed one of their overpowered stacks. Still, I'd better think spells are the key to victory if I've chosen to try Impossible difficulty on the mage class.

In addition to spells, you have rage abilities. You get rage during combat by dealing and receiving damage. Rage abilities are a lot like spells, but there are only 9 different ones and they get more powerful as your familiar levels up.

What makes rage abilities special, when compared to spells, is that they often allow you to deal with enemy units in ways that kind of ignore how powerful they are. Chief among these is Jealousy, which let's you make an enemy unit go uncontrolled, attacking friend and foe alike - usually friend since their foes are all the way across the arena still. Jealousy certainly has restrictions on how it is used, but it does not depend on the leadership of the stack. You can sometimes use jealousy to turn the enemy's most powerful stack against them. There are also two abilities that kill a percentage of the troops in a stack, which is nice as an equalizer; and an ability that makes a small number of hexes impassible, which gives you get tactical options.

On Impossible difficulty, rage earned from combat is halved, but I still anticipate rage playing a very significant role in make the impossible possible.

Better Units
If it's all zombies vs. zombies then the side with more zombies is just going to win. Attack, defense, spells and rage can equalize the fight, but in the end zombies just crack each others' heads. Units in King's Bounty, however, are much more complicated than that.

When I said above that peasants beat black dragons, that would be true on a map with only two hexes. But in reality the black dragon wins every time. While peasants have an initiative of 3 and a speed of 2, the black dragon has an initiative of 6 and a speed of 8. The dragon can also fly. Basically, the peasants will never get to even attack the dragon unless the dragon allows that to happen. Of course if the dragon attacks the peasants they still get to counterattack. However, every three rounds the dragon has the ability to move up to it's full speed and deal 110-140 damage to everything it flies over with an 80% chance on inflicting the burning condition. That does not allow counter attacks. So if you put 1 black dragon up against a stack of 1 million peasants then 48000 rounds of combat later the dragon would emerge victorious.

There are several ways that units are better than other ones. Obviously having more initiative more speed and a way to attack without being counter attacked is a sure victory. |A less obvious way to be better is hidden in the black dragon example, and that is large health pools. The peasants have to do 1000 damage to win but the entire time they are dealing damage the black dragon is doing full damage back. The black dragon has to do 3000 damage to win, but wen it's done 300 damage, it's reduced the peasant's attack strength by 10%. In fact, if the attack and defense calculations didn't cap at 3 and the dragon was allowed to use all 69 points of advantage is has it would win against the 500 peasants. However, if you pit 1000 dragons against 500,000 peasants then then dragons only manage to defeat about a third of the peasants before dying in a straight fight, because with that number of creatures the advantage from having a high health pool is neutralized. In the early game, having aunit with a large number of hit points is very useful.

There are also a variety of abilities that allow you to control fights in other ways.

Next time I'll move beyond the abstract and start talking about the specific things I did to get through the impossible very early game.

Monday, 18 May 2015

Impossible: introduction

King's Bounty games have four difficult settings: Easy, Normal, Hard and Impossible. The difference between difficulty settings varies a little from game to game, but basically what is affected is the rate at which you gain rage and the amount of enemies you have to face. In King's Bounty: Dark Side, Impossible difficulty means fighting 170% of the enemies you would have fought on normal.

To get a sense of what that means, let's talk a bit about how the game plays. Battles take place on a hex field. When a unit attacks another unit in melee, the victim counterattacks, but each unit can only counterattack once a turn. When a ranged unit attacks in melee, it does half damage. Of course there are lots of exceptions to these rules for individual units, but basically your units walk towards each other and fight.

You have five different units in your army, and how many of each you get is determined by your leadership score. An imp, for example, has 40 leadership, so you if you 300 leadership you can have 8 imps in your army. Because you can only have 8 imps regardless of whether you control on stack of 8 imps or two stacks of 4, and because you only have five stacks, usually you'll want five different types of units to maximize your total army.

So lets say you have 300 leadership and go into an even fight with an enemy with 300 leadership. Both of you have zombies. Zombies have 30 leadership, so you each have 10. Zombies attack for 3-4 damage each and have 36 health. So an attack from the one stack to the other does either 30 or 40 damage, either killing on zombie or not. The battle, obviously, is a coin flip, though strike first carries an advantage.

Now instead of 10 zombies the opponent has 17. Your zombies strike for 30 or 40, with a 50% chance of killing one enemy zombie. Their zombies strike for 51 or 58, killing one of your zombies and half killing another. Next round you attack with 9, then maybe only 7. On average when their zombies have wiped out yours, they've still got 14 left.

So 70% more isn't really 70% more. More leadership increases both the health and the damage of the stack, so 170% is a lot more like 289%.

Enemy stacks were larger than yours most of the time on Normal difficulty, so it's less like three times the strength and more like four or five times the strength. They don't call it impossible for nothing.

Of course you don't march your units into the middle of the field and fight to the death, this is a game of tactics, but when facing a force of five times the strength, where their ranged units can shoot down your troops in a round or two, and their melee units can half kill yours with a single attack - there is only so much tactics can do unless some truly ridiculous nonsense going in your favour.

I recently started playing Impossible difficulty with the vampire - the wizard class of Dark Side. I'm not sure this is exactly a Let's Play, but I'll be posting about my progress as I try to find the right mix of nonsense to get through.