Archive for March, 2007

Challenges, Fate and Tactics

Thursday, March 29th, 2007

Conflict resolution of some sort or another forms the backbone of most games.  In formal game theory of the type originated by von Neumann and Morgenstern it might take the form of a pay off table.  In a game like chess the movement abilities of the individual pieces determine how an enemy piece is “captured.”  In a game like risk a six sided die and the laws of probability rule the day.  The core mechanic that Armageddon Empires is built upon is called a “Challenge” and although luck plays a role, if you set your challenges up correctly you will succeed most of the time.  Basically any time a result must be determined in Armageddon Empires two attributes ranging from 1 to 10 in strength are compared and converted into dice.  Each die has six sides with half containing symbols that denote success and half blank faces denoting failure.  Sometimes the challenges are opposed as in a combat challenge where the attacker roles his dice pool and counts up the successes and matches the result against the defender, who also rolls his dice pool and counts up successes.  If the attacker’s total is higher than the defender’s total then the difference is applied as damage.  Some units might have special abilities that modify the damage either positively or negatively so the final amount subtracted from the defender’s hit points can vary.  Below is an example of a ground to ground combat challenge where an Imperial Marines Unit from the Empire of Man has initiated an attack against an independent pack of Howlers.  The Marines have an attack of 7 and the Howlers have a defense of 1.  The Howlers get a bonus of 1 die from the terrain since they are defending .  You can see the two sides dice pools lined up here in the challenge resolution display. 

BasicChallengePad

Notice that the Marines have rolled 5 success and the Howlers came up empty.  So 5 damage points would be applied to the Howlers, who only having 2 hit points total are destroyed and removed from the battle.

What if the Imperial Marines had rolled 0 successes?  Well in this case they would still have a chance to inflict some damage.  Next to the Marines’ hit point display is a box that shows “Fate: 5.”  This unit is being led by a hero who has a Fate attribute of 5 and these Fate Points can be used to re-roll failed dice.  When a re-roll is possible the “Spend” button is enabled and each time you click on it 1 Fate Point is subtracted from the pool and a failed die is re-rolled.  If you use Fate wisely it can turn the tide of a battle.  This is why having a hero lead an army is so important.  Not only can bigger armies be formed but also more effective ones as well.  Fate is available in many situations where an army is led by a hero.  There are a few exceptions however: 

In “Air to Ground Challenges” the defending ground unit does not get a fate pool

In “Ground to Air Challenges” the attacking ground unit does not get a fate pool

In “Retreat Challenges” the side pursuing the retreater does not get a fate pool

In “Sabotage Challenges” the defending side does not get a fate pool against the saboteur unless an Intel Center is present in the same hex

In “Assassination Challenges” the target hero does not get a fate pool agains the assassin

Even if a fate pool is not available you still have another way to influence the outcome of a challenge.  If you look at the right side of the challenge resolution display you will see a card slot box labled “Play Tactic Card Here.”  During a challenge if you can pay the Action Point cost for the Tactic Card you will have the opportunity to drag a tactic card that you have created to the box and release it.  The card’s effect will then take place.  Effects range from rerolling failed dice to removing success die from the enemy’s dice pool.  Here is a sample of the fate cards available to the Xenopod faction:

XT

Challenges can also be unopposed.  In this case the defender’s dice pool represents a target threshold level that must be met by rolling the challenger’s dice pool.  When your heroes create technology or tactics cards this is what occurs.  Depending on the level of the card you want to create you will have to roll a certain number of successes.  You can use tactics cards in these situations as well.  

AI Wars

Thursday, March 15th, 2007

The plumbing for Armageddon Empires is in fine shape and only occasionaly do I get an error or bug that I have to stamp out in the interface or basic game logic.  The last several months have been almost entirely focused on getting the AI to play a competitive game.  Along the way I have had my fair share of groans as the AI players did some boneheaded things.  I’ve also been pleasantly surprised at some solid execution and even I might dare say “emergent” type behavior.  Without going into too much technobable that might bore the non code junkies, I built the game from the ground up with the AI in mind.  Since the game was going to be a solitaire game, I new that a solid AI would be crucial to a “fun” or “challenging” experience.  My computer coding skills go back to the early eighties when I was an undergad studying electrical engineering.  I coded in Pascal on a VAX 11780.  The year before I arrived at the school, they had just gotten rid of punch cards and switched to terminals.  Wooden ships and iron men.  I’m not a particularly talented programmer but I have what you might call the Sharingan Eye if you are a Naruto fan.  I’m a copy ninja.  If I see some good examples I can nuke them out and elaborate a little.  The AI for Armageddon Empires is inspired from many books I read but “Programming Game AI by Example” was probably the biggest help.  http://www.amazon.com/Programming-Game-Example-Mat-Buckland/dp/1556220782

 Mat Buckland has a section on Goal-Driven Agent Behavior that helped me design a goal based architecture for my AI players.  Basically each AI player has a goal qeue that stores a goal object.  The qeue is sorted by priorities assigned to each goal and every turn the AI moves through the qeue processing the goals and spending Action Points and resources as best it can.  The generation of goals and the appropriate priorities is a tricky thing but I divided up the possibilities into several basic categories….Exploration, Resource Collection, Offense Ops, Defense Ops, and Support Ops.  If a threat is detected then the priority for Defense Ops is increased.  More defense type goals will be generated and they will have a greater urgency. 

 Time after time I ran across a problem where I needed to rate options and come up with some type of metric to compare them.  I implemented my own fuzzy logic system inspired by Mat’s examples as well as others.  Fuzzy logic is a great way to take a bunch of crisp parameters like Attack = 8 dice, Defense = 2 dice, and HP = 5 points fuzzy them up into Attack = “Above Avg”, Defense = “Below Average” and HP =  “Average” and then manipulate them with some logic rules.  For example, If Attack = “Above Avg” then “Target Desire” = “Strong”, If HP = “Above Avg” then “Target Desire” = “Below Avg.”  By using a thing called “The Combs Method” you can drastically reduce the number of rules like this.  The end result is a target rating that you can use to compare with others.  Once you have that you can pick the highest, lowest or use some other scheme to come up with the best choice.

So a goal based architecture and extensive use of fuzzy logic are the two big components.  Finite state machines are also a key component but they are tireless work horses that are so common they are almost taken for granted.  Each goal object is really just a finite state machine of a sort.  These programming techniques make up the Brains of the AI players but another important part is the actual architecture of the game itself.  I really wanted to make a game whose AI’s saw the same thing that the human player did.  So information storage and access was designed from the outset to facilitate this.  Each player and AI has an Intel Object that stores it’s own copy of what the player or AI knows about the game board.  Every turn or as a playing piece moves and observes more of the map that information is transfered from the main game map object to the players’ Intel Objects depending on what they can see (as determined by dice rolls that make observation checks)  The AI can only see what its armies deployed to the board can tell it.  Sounds great huh!  Well it opens up a whole new challenge for getting the AI to seek out the information it needs or even infer (gasp!) information from what it does not see.  Countless times I’ve had to dig into the reasons why an AI player passed up opportunity X.  Did the Intel Object not have the info and it simply did not see it?  Did it rate the chance of success too low? If so should the parameters be adjusted so such a no-brainer is recognized. 

Hidden information from the human can make the AI look stupid.  The game that I was playing last week as the Machines is a good case in point.  After my initial exploration and expansion, the Imperials kicked my butt pretty badly and forced me to pull back my supply lines to a more defensible perimeter.  I hunkered down and started rebuilding an army to go back out and kick some human butt.  6 or 7 turns clicked by and I was completely unmolested.  I thought, “damn!, something is broken.” The AI should have pressed forward by now and come after me.  He had harrassed me with some air attacks but nothing serious.   I dug back into the saved files for each turn and was surprised to discover that the Humans and Xenopods had made contact right above my little holdings and had been savaging each other a mere hex from my stronghold.  Both had been moving in for a kill and stumbled upon the other.  Soon their aggression rating with each other had built up enough that they were going at it full tilt and leaving puny me to be dealt with later. 

That’s a pretty basic description of the AI.  Here is a screenshot of a game that I am currently testing that has had a pretty epic sweep.  After getting some great resources and finding some excellent specials (the ones that provide a free outpost are real momentum accelerators) I pushed headlong into Xenopod territory.  Playing as the Imperials I found some key allies out in the wastelands as the humans are wont to do and I had a nice army built around some advanced combat mechs.  I got a little ahead of myself and left my supply anchor lightly defended.  A Xenopod army captured it and that left my mech army out of supply and crippled.  They fought a series of battles retreating back to a hex in supply.  The momentum has definately swung in the Xenopods favor.  I’ve got a huge stockpile of resources and good scientists so once I can get some tactic cards created to ensure success I’m going to build a city killer and see if I can even the odds. 

XenopodAdvanse

Exploration and Expansion

Thursday, March 8th, 2007

As is the case with most 4X type strategy games (eXplore, eXpand, eXploit & eXterminate for you behind the power curve newbies) the early game in Armageddon Empires is a lot of fun.  There is a certain joy in exploring a new landscape every game.  Since each terrain tile is fully modular and every map is randomly generated each turn, you can get some interesting topographical challenges.  The first thing you notice is how open the map is.  Are you facing lots of sandy desert, dunes and wasteland or is there a mountain chain or line of crags and badlands dominating the map somewhere?  From a programming stand point getting an interesting map generated every game was a small challenge.  As the famous Dr. Forrester once said, “It’s really quite complicated actually, but all you need to know is…” that I generate a height field based on a random seed or two of the highest level and follow it with some Markoff chain processing….then perform some errosion and wallah, you get some interesting maps that make topographic sense…each as unique as a snowflake.  The first thing you want to do is get some unit/hero cards deployed to your initial stronghold and start exploring the board.  It can be both dangerous and rewarding.  The best units to start exploring with are dedicated recce units or special agent type heroes that have the “Stealth” special ability.  Stealh on any unit or hero will cut the strength of enemy observations in half.  Basically dice are rolled behind the scenes to determine whether a unit is spotted.  Getting a stealthy unit out first or one with the ability to see into neighboring hexes with the “Recce” special ability will decrease the chance of losing the unit when it stumbles upon a group of Tentacle Beasts or Rad Zombies.  As your units explore the wasteland they will come across “Specials” that will give them extra resources, attachment type cards or even allies that join your cause.  “Specials” range from lost nomad caravans to hidden secret vaults filled with exotic technology.  Some of the stuff you stumble across can have a big impact on play so it’s best to get out there and find it.  An enemy that comes across a rare city killler nuke is going to ruin your day if he finds your HQ and has the means to deliver it on target.  Here is a screenshot from a game that I am testing out right now.  I’m playing as the Machines and have explored the local area.  Along with some resources to jump start my deployments, I found a cache of flechette guns that I attached to a unit of Advanced Cyborgs.  It took me a while to build some resource collectors in the tile that I place below my stronghold but eventually I got it done.  After that I built an army and drove out a group of canibals from the ruins of the great city just north of my stronghlold.  It contained “materials” and “tech” resources which is just what my faction needed and I hurried to get some collectors up and running there.  Just as I finished construction, those pesky humans showed up and built a tech collector.  You can’t see the Imperial Army that showed up from the north because I crushed it.  However, I’m going to have to get a move on it and find the Imperial HQ.  I have already lost two units of spider bots and a lich platoon trying to probe forward and find it.  Human airpower is a killer if they catch your units out of supply which really lowers your defence. 

ExplorationExpansion