Advertisement

Wargame AI

Started by March 05, 2008 09:39 AM
7 comments, last by WilliamvanderSterren 16 years, 8 months ago
Hi, I'm writing a JAVA wargame (old fashioned hexes and counters etc). What's the best way to code a wargame AI? I don't mean the path tracing, or finding best odds or lowlevel things like that, I mean the high level strategy, when to attack, when to defend, how to break through the enemies lines, how to defend an area etc. I want it simple, no Neural Networks or anyting like that. Most articles are vague on how one actually implements an AI. What I want to know is how one actually codes it. A big list of if-elses??? Thanks
That's tough to answer in a message board post. There is no ONE way to do it. And any solution will incorporate multiple types of AI - whether it be influence maps, rule-based systems, hierarchical task networks, goal-based planning, or simple random numbers.

The best solution, as always, is to solve each problem one at a time. "How would I make this ONE decision? What information do I need? What factors are important?"

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement
That is hard to answer. What I've done is to try to make the high-level decisions first, which in my case is whether to retreat or not. Second, if in attack position, do that. Then test if the unit can, or should, use ranged attacks. Finally, if none of the above, move to a "better" position.

It's simple to code, and works. You will get a much better AI if you incorporate something like influence maps to plan strategy, and maintain a "line" of attack or defense. The AI Game Programming Wisdom series has a lot of articles that will help.
You need to design the behaviors you want *before* you choose how best to implement them. If you dont know what you want your cpu player to do and not to do, you can't do any worthy AI.

Go back to the drawing board!
Some search terms for this site: "influence map", "Strategic AI", "Skirmish AI", "hex game AI"

There have been a number of possible solutions posted over the past couple years.

-me
Yeah, I find the best first step to take when trying to come up with some "AI rules" is to play the game myself, but take note of every decision that I make and why I made it.
Then look over the transcript of how you decided what to do, and try to generalise that into rules that you can implement for the AI.
Advertisement
Quote: Original post by Hodgman
Yeah, I find the best first step to take when trying to come up with some "AI rules" is to play the game myself, but take note of every decision that I make and why I made it.
Then look over the transcript of how you decided what to do, and try to generalise that into rules that you can implement for the AI.

That's a good approach. The difficulty, of course, is step 1: Decide on an overall strategy. But still, that has merit. I may re-examine my AI with that in mind.
Thanks for your replies.

Just as I feared! No magic bullet. ;)
Influence maps seem a good method for finding defensive lines etc...

But at least I now have a starting point, a pen and paper... ;)
Two (concrete) suggestions:
- pick up Chris Crawford's book 'On game design' (2003), and read the chapters describing the design of his wargames (Tanktics, Eastern Front 1941, Patton vs Rommel, Patton Strikes Back). These are games from the late '70s, '80s and early '90s. Chris describes how to use position evaluation to generate moves. Although you can find some of Chris' articles on the internet (and even source code for Eastern Front), the book covers wargames in a bit more detail, and is an inspiring read.
- download LGeneral and study its source code. LGeneral is an open source reimplementation of SSI's Panzer General wargame (1994). The AI consists of some 6 C files. I haven't compared LGeneral's AI to the original game's AI, but the original game was quite fun.

Keep in mind that part of the 'AI' in a wargame is the result of scenario designers carefully tweaking and setting objective values and scheduling reinforcements.

William

This topic is closed to new replies.

Advertisement