Sign in to follow this  
Hinkar

Wargame AI

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?"

Share this post


Link to post
Share on other sites
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 [u]AI Game Programming Wisdom[/u] series has a lot of articles that will help.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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... ;)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this