Open Source Developer
Well it’s official - I’m an open-source developer now! Not that I’ve left my “real” job - far from it. In my spare time, I’ve been digging through the source code for an Axis & Allies clone game - TripleA. TripleA is built in Java 1.5 (or 5.0 for those of you that enjoy marketing hype) and is pretty fun - it even has multiple other variations on the game using the same set of rules. Here are my two patches so far:
1) Weak AI and Random AI improvements to allow moving into free “neutral” territories (#1617)
2) Alt+Click to select 1/10 of a unit stack when moving or attacking - good for working with large stacks of armies (#1618)
The fun part is yet to come - I’ve started working out the logic that a “Good AI” would have, and throwing a few ideas back and forth with one of the other developers. So what makes up a “Good AI”? My goal is to build an AI that is intelligent enough to move into battle and reinforce the front line (as the Easy AI can do today), but that is also smart enough to recognize incoming troops and move to intercept, deal with air and sea units to their full capacity, and be able to control multiple-fronts.
The current direction I am taking is to set up a framework of “Plans”, a single Plan could be anything from “attack this territory” to “destroy as many enemy units as possible” to “take the enemy capitol” to “help defend an ally”. All plans would vote on each other. Since some Plans would be unable to be executed directly in a given turn (take the enemy capitol), voting would allow those Plans to support like-minded Plans until the AI’s units are close enough to directly implement the plan.
The second part is the need for a more accurate method of estimating a battle win or loss. Currently all AI’s use a “get strength” approach, and compare each army’s strength. This does not accurately take into account first-strike units, such as subs or anti-aircraft, but otherwise does a relatively good job of estimating the outcome. I’ve come up with an alternative algorithm that I believe is more accurate (using A for attacker and D for defender:
1) estimate the number of hits that would be made by first-strike units for A and D
2) estimate the average number of hits A’s armies would make, excluding units hit by D’s first-strike hit count (repeat from D’s perspective)
3) divide D’s total number of units by A’s hits and you have a rough number of rounds until A wins (repeat from D’s perspective)
4) the side with the fewest number of rounds is projected the winner, and we calculate the percent difference to estimate by how much
This appears to match relatively well with some example scenarios that I have put together. The next steps will be to set up the interface for Plan, defining a “PlanFactory” for each type of Plan, and finding a way for all the plans to store their intended action so it would be understood by the other Plans. I believe they have a “Route” object already in the game, and specifying minimum and optimal number of troops or IPC’s needed for a Plan may be enough.
Has anyone else worked on artificial intelligence? Do you have any recommended books or online resources?
Tags:
NickelNuts.com » Blog Archive » Be Adolf Hitler for a Day on 20 Nov 2006 at 11:00 am
[…] Although my buddy Nate is now spending his time rigging Axis and Allies so that he has an unfair advantage, that shouldn’t stop you from playing this game. It used take days to play one game, and that was only after months of planning to find four WWII history geeks that were willing to invest the time. Now, you can play in the comfort of your own home (at a much quicker pace) either against the Nate Dork Borg, or other live dorks online. […]