Coder Diary #10 -- New A/I Bells & Whistles

John Tiller's Campaign Series exemplifies tactical war-gaming at its finest by bringing you the entire collection of TalonSoft's award-winning campaign series. Containing TalonSoft's West Front, East Front, and Rising Sun platoon-level combat series, as well as all of the official add-ons and expansion packs, the Matrix Edition allows players to dictate the events of World War II from the tumultuous beginning to its climatic conclusion. We are working together with original programmer John Tiller to bring you this updated edition.

Moderators: Jason Petho, Peter Fisla, asiaticus, dogovich

Post Reply
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

Coder Diary #10 -- New A/I Bells & Whistles

Post by berto »


Coder Diary #10 -- New A/I Bells & Whistles


If you are a die-hard PBEMer, read no further. The following will be of no relevance to you.

If you play the A/I, however, you might find the following discussion interesting. It's time to spill the beans...

The A/I.

Everybody disses it, nobody likes it. Apart from our just giving up and we all do PBEM (shhh [:-]), what can be done about it?

Much more than you think!

In computer war and strategy games, how is A/I usually implemented?

[*]Brute force it. From the current game state, going forward, examine and evaluate all possible future game states, or at least game states several turns advanced. Then select the move(s) pointing in the direction of the "best" future game state(s). (Like some chess programs. Totally impractical for a game as complex as the Campaign Series.)
[*]Mostly internally, in the code, but with limited outward ability to script and direct the A/I. (Like John Tiller's BattleGround Series of games.)
[*]Largely internally, but with an extensive event and game parameters API, and even a full-fledged user moddable scripting language. (Like the PI game Europa Universalis, or AGEOD's American Civil War & co.)
[*]Entirely hard-wired algorithmically, but entirely closed to the player -- totally "black box".

The Campaign Series uses that last approach. None of Tiller's Campaign Series A/I is scripted. It's done entirely through algorithms and data. Amazing!

Alas, the Campaign Series A/I is also totally "black box". Heretofore, there was nothing we could do about it. Take it or leave it.

Somehow, it all seems to work. Or doesn't work, as we so often see the game A/I doing stupid and even randomly mindless things.

I won't kid you: The Campaign Series A/I code is hard to decipher. It's complex, inscrutable code. I am months away from fully comprehending it. Many more months away from feeling confident enough to perform brain surgery -- recode algorithms, implement new data sets and logic layers.

Putting intelligence into the game's Artificial Intelligence -- a daunting task. It will require lots more time, patience, and study, not to mention some really tricky coding. A long-term project.

What to do in the meantime?

One thing: I have implemented:

[*]Continuous A/I Play mode.

With Continuous A/I Play mode, we can fire up any game, any scenario, and watch the A/I play itself, from beginning to end, without our having to touch keyboard or mouse or interact with the game in any way. Just sit back and watch. More than for just entertainment purposes, we can put this new auto A/I play to good use. More on this a bit later.

What else can we do?

There are several game parameters that help guide the game's A/I. John Tiller had hard-coded these parameters, made them invariant and constant. I have recoded them as variables, modifiable in two separate ways.

Here is one way, via a new configuration file

[*]ai.ini

in the Notepad window to the upper right of this screenshot:

Image

(From inspecting the game code, I can see other hard-coded constants and probabilities where I might add to the AI parameters list.)

(In the AI Dump window, the first lines in every couplet are for Side A, the second lines for Side B. Note: AI Dump will likely be removed from the final publicly distributed release(s). AI Dump is there during our development and testing phases only.)

[*]Circled in blue, you will observe the hard-coded AI_* constant defaults (as specified in the code).
[*]Circled in green, you will observe the _AI_* resets, both sides, as specified in the ai.ini file.
[*]Circled in red, you will observe the _ai_* values as the game engine currently processes them, and as modified by in-game actions (by the player and/or by the code).

If there is no overriding ai.ini, the game reverts initially to the hard-coded AI_* parameter defaults.

Players may (using Notepad or whatever) edit ai.ini to tweak those parameters however they please, thereby affecting the game A/I's behavior.

Such tweaks apply at game's start (when ai.ini is loaded from disk), and throughout. Unless and until, in-game, players try any of the menu options:

[*]Side A Audacious A/I
[*]Side A Cautious A/I
[*]Side B Audacious A/I
[*]Side B Cautious A/I

Audacious A/I tweaks the above parameters to encourage more risky behavior, such as offloading units nearer the enemy, sending "unhealthy" units into battle, etc. Cautious A/I does just the opposite: discourages risky behavior -- increases standoff distance, keeps unhealthy units out of harms way, etc.

So, players can affect the game's A/I behavior either by, at game's outset, specifying the A/I parameters in the ai.ini file, else by making the A/I side's profile Audacious or Cautious, at any time, based on whimsy, or out of a desire to nudge the A/I to adopt one or the other behavior more appropriate to the current game situation.

Audacious and Cautious are two behavior profiles. We might devise others (and therefore create still more menu options).

Another way we can help guide the game A/I: by specifying Side A or B A/I Aggressiveness, the items circled in magenta.

In CS game terms, what is meant by "Aggressiveness"? From the game docs:

Image

(Unfortunately, the red circled sentence in TIP #7 is erroneous. In fact, the highest 100 Aggressiveness setting applies both to "all out" attack and "die where you stand" defense. By setting lower Aggressiveness, both attack and defense are less resolute, less forceful.)

In the screenshot A/I Aggressiveness Dialog, I am about to set the Side B Aggressiveness to 80. The Side B 80 Aggressiveness overrides the default 100, which in the pictured scenario is the same for both sides.

Where do these Aggressiveness values come from? From the .scn files. The scenario designer specifies Aggressiveness values, both sides, in the edit Header Dialog:

Image

When the scenario is saved, the Aggressiveness values (among many others) are written to the .scn files. For example, the Bir_Gifgafa_1967.scn file begins with

11
Trouble at Bir Gifgafa
0 0 0 102
0 0 0 0 7
3 0 0 0 65 75
0
100 200 350 500 10
100 100 0 0
...

So by selecting the A/I menu options

[*]Side A A/I Aggressiveness...
[*]Side B A/I Aggressiveness...

you, the player, have the option to second guess the scenario designer. Think you can do better? Do you prefer a more Aggressive A/I opponent? A less Aggressive A/I opponent? Or maybe you just want to tinker? With the new A/I Aggressiveness controls, now you can! (Or will, in the next release. [:)])

Tweaking A/I Aggressiveness does not produce radical changes in the A/I behavior, only nudges the A/I in certain directions.

By setting the attacker's Aggressiveness to 100, don't expect automatic blitzkrieg-like attacks. The A/I attacker will pursue its normal (but randomized) course, but with a bit more oomph (AttackHigh) to its local attacks.

By setting the defender's Aggressiveness to 0, don't expect them to run away and hide. No, they will defend more or less like "normal" (normal to the rest of the A/I code and what it ordains), but be a bit more yielding (DefendLow) in its local defenses.

Eventually I might widen the scope of Aggressiveness. Also the other afore-mentioned Audacious A/I and Cautious A/I; in the code, their applicability too could be extended.

More options:

[*]Side A Shifting A/I.
[*]Side B Shifting A/I.

How do they work? First off, if you choose Shifting A/I, it overrides Audacious A/I and Cautious A/I; you can't have both. (Obviously, Audacious A/I precludes Cautious A/I, and vice versa.)

Secondly, in a random shift direction, the game will have the A/I go Audacious for (random) X number of turns, also tilt towards increased Aggressiveness; or go Cautious for (random) X number of turns, and become less Aggressive; then stay Audacious/More Aggressive, or stay Cautious/Less Aggressive; else revert to default neutral (neither Audacious/Aggressive+ nor Cautious/Aggressive-).

That is to say, the A/I would not jump immediately from Audacious/Aggressive+ to Cautious/Aggressive- (or vice versa). It would have to pass through the neutral middle behavior if and when passing from Audacious/Aggressive+ to Cautious/Aggressive- (or vice versa).

At each A/I behavior stage, the A/I would linger there for (random) X turns before (possibly) moving on to a new stage.

Depending on the internal "dice", it is entirely possible with Shifting A/I for the A/I to go Audacious/Aggressive+ and stay there for the entire game. Or go Cautious/Aggressive- and remain there. Or stay neutral throughout. Spend most of the game Audacious/Aggressive+, then turn Cautious/Aggressive- toward the end. Or start out Cautious/Aggressive-, then go Audacious/Aggressive+ later. In longer games, go Audacious/Aggressive+, then tend towards Cautious/Aggressive-, then back to Audacious/Aggressive+, then...

Important: With Shifting A/I selected, the player will not know directly whether the A/I is in Audacious/Aggressive+ mode, or Cautious/Aggressive- mode. (As stated, we will be removing the AI Dump window in the game public release.)

I will probably code this such that, if the player chooses Shifting A/I, it locks out Audacious A/I and Cautious A/I, also the Aggressiveness controls, for the remainder of the game. If the player wants to remain in charge, he/she should just use (or not) Audacious A/I or Cautious A/I, and/or the Aggressiveness controls, and refrain from selecting the lock-in Shifting A/I option.

Will Audacious or Cautious mode improve the A/I's behavior? What about increasing or decreasing the A/I Aggressiveness? Besides John Tiller, who knows?

Even in its occasionally laughably bad state, the Campaign Series A/I is not entirely ludicrous, totally off the wall or random. If you are forgiving, it can give you a tolerably good game, especially if you play the attacker while the A/I manages a static defensive position. It's awesome what John Tiller did with his A/I, even if it falls short of being fully satisfying or acceptable.

Back in the mid 1990s, when John Tiller developed and refined the Campaign Series and that game's A/I, how did he "optimize" the A/I? Through reason alone? Intuition? And/or empirically, by running test game after test game? If the latter, did he automate the process? This is something I would like to achieve: totally automating the testing process, having the ability to run the game in batch mode testing hundreds and even thousands of trial games. Not just by reason alone, but also by way of discovery, we might chance on just the right mix of A/I parameters (and eventually also refined and new internal algorithms) that will optimize the game's A/I. (Optimize in the sense of maximizing of Victory Points. Another metric might be plausibility of A/I behavior. Does it act more or less like a real commander might?)

Can I/we do better than John Tiller? Maybe, maybe not. We may never find the Secret Sauce or improve on Tiller's parameters. (And I may never be able to improve on his coded algorithms.) But it will be interesting to find out.

By opening up the game A/I in limited fashion to you, the players, and giving you the power to tweak its behavior, we can enlist you in the quest to develop the "perfect", "optimized" A/I.

Two heads are better than one. Two hundred, two thousand, ... heads are better than one. (Mine, or John Tiller's.) We may never by ourselves, just I alone and/or the dev team only, discover the Secret Sauce of an effective and plausible A/I. But working together as a community we maybe just might!

Just as we give you the players the tools -- edorg, edmap, edit -- to mod the game, we will give you the tools -- ai.ini, the in-game A/I menu options -- to mod the A/I also.

With the new Continuous A/I Play mode, you can try this or that parameter tweak, or combinations of tweaks, then watch and observe how the A/I plays itself out. This will facilitate your personal testing. Or maybe just provide you some amusement.

We might envision friendly -- or heated! -- forum debates between players advancing their favorite ai.ini configuration, parameter tweak, or playing mode.

Thinking further down the road, we might someday anticipate:

[*]Encoding algorithms to -- Artificial Intelligently -- have the game adapt its behavior to go Audacious/Aggressive+ or Cautious/Aggressive- (or whatever) automatically, as changing game conditions warrant. Audacious/Aggressive+ on the attack, Cautious/Aggressive- on the defense? Aggressive early in the game? Later?
[*]Specifying that Axis (for example) A/I always tends to play one way, Allied another. Or Bulgarians usually like this, North Koreans like that. A/I profiles by nationality!
[*]Giving scenario designers the means to tailor A/I behaviors to their scenarios. Go one way with one engagement type; go a different way with another. Either by specifying A/I parameters in the .scn file, or suggesting ai.ini tweaks in the scenario briefing.

Who knows where this quest for the "perfect" A/I might take us?

Again: What can we do about the CS game A/I?

And again: Much more than you think!

Until the next time ...
Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
User avatar
budd
Posts: 3070
Joined: Sat Jul 04, 2009 3:16 pm
Location: Tacoma

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by budd »

As always sounds good. Any idea "vaguely" when we can get our hands on this stuff. By year's end, next year ect. ect.

Thanks for doing these diaries...looking forward to getting into CS again with these changes.
Enjoy when you can, and endure when you must. ~Johann Wolfgang von Goethe

"Be Yourself; Everyone else is already taken" ~Oscar Wilde

*I'm in the Wargamer middle ground*
I don't buy all the wargames I want, I just buy more than I need.
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by Crossroads »

Excellent work as always, Berto! :)
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by berto »

ORIGINAL: **budd**

As always sounds good. Any idea "vaguely" when we can get our hands on this stuff. By year's end, next year ect. ect.
Erm, sorry, my standard official reply:


Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
User avatar
wings7
Posts: 4586
Joined: Mon Aug 11, 2003 4:59 am
Location: Phoenix, Arizona

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by wings7 »

Wow, this is great! I have not done any gaming via PBEM...this may change now!

Patrick
Please come and join and befriend me at the great Steam portal! There are quite a few Matrix/Slitherine players on Steam! My member page: http://steamcommunity.com/profiles/76561197988402427
User avatar
wodin
Posts: 10709
Joined: Sun Apr 20, 2003 3:13 am
Location: England
Contact:

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by wodin »

How about the AI using the new units?? [;)] Is that as complex as trying to improve the AI??
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by berto »

ORIGINAL: wodin

How about the AI using the new units?? [;)] Is that as complex as trying to improve the AI??
[:-]

[:D]
Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
User avatar
kool_kat
Posts: 558
Joined: Mon Jul 07, 2008 1:10 pm
Location: Clarksville, VA.

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by kool_kat »

Hey Berto; [8D]

So, boiling it all down to NET comments on this thread. The AI is "broken." Every player knows it. It will be a long, complex, and difficult process to "fix" HAL. In the intern, either live with a "broken" AI, play exclusively PBeM with human opponents (that's what I do!), or move on to another game platform.

The official Matrix Game comments on "when" all this stuff will get fixed and deployed is the proverbial "no comment." [;)]

Got it. [:)]
Regards, - Mike

"You have to learn the rules of the game. And then you have to play better than anyone else." - Albert Einstein
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by berto »

ORIGINAL: mwest

So, boiling it all down to NET comments on this thread. The AI is "broken." Every player knows it.
Yes, we're all pretty much agreed.
It will be a long, complex, and difficult process to "fix" HAL.
Definitely.
In the intern, either live with a "broken" AI
Let's break that into three options:

[*]Just accept it as is, play it as is, like before.
[*]Using the newly provided tools and tweaks, "fix" -- or rather, try to improve -- the A/I for your own private benefit.
[*]The above, but pitch in and join in a community effort to discover a better A/I.

Of course, none of that lets the dev team and me off the hook or absolves us of our responsibilities. We still have to keep at it (coding new and better algorithms, running test trials, etc.).
play exclusively PBeM with human opponents (that's what I do!)
That suits a lot of folks. Different strokes for different folks.
or move on to another game platform.
True, that's always an option, it goes without saying.
The official Matrix Game comments on "when" all this stuff will get fixed and deployed is the proverbial "no comment." [;)]
Not exactly. (And not that I'm the official "voice" of Matrix on anything.) Post #1 above is "our" comment.

Also, about the "get fixed" part: In a sense, the A/I will never "get fixed", will it? Nobody anywhere has ever achieved a "fixed" A/I (see Turing Test), not even IBM's Deep Blue:
Deep Blue was a chess-playing computer developed by IBM. On May 11, 1997, the machine, with human intervention between games, won the second six-game match against world champion Garry Kasparov by two wins to one with three draws.[1] Kasparov accused IBM of cheating and demanded a rematch. IBM refused and retired Deep Blue.[2] Kasparov had beaten a previous version of Deep Blue in 1996.
So, the new CS A/I bells & whistles outlined above are kind of like Deep Blue's "human intervention between games", right?

[;)]

All we can do is to give it our best effort, to keep trying. It's a journey, not a destination.
Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
User avatar
junk2drive
Posts: 12856
Joined: Thu Jun 27, 2002 7:27 am
Location: Arizona West Coast

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by junk2drive »

bump 10
Conflict of Heroes "Most games are like checkers or chess and some have dice and cards involved too. This game plays like checkers but you think like chess and the dice and cards can change everything in real time."
vonkrieg
Posts: 11
Joined: Tue Nov 04, 2014 6:28 pm

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by vonkrieg »

Yes, the black box concept is pretty much how I look at the game itself. I don't really dig into the mathematics of the attack and defense CRTs, I look at the results and over time I develop experience on just what to expect. It sounds like we can use this approach to explore the limits of the AI. It will also allow us to vet the scenarios under different circumstances without going full PBEM which while enjoyable is time consuming.
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

RE: Coder Diary #10 -- New A/I Bells & Whistles

Post by berto »


After Middle East is out, things might ease up a bit. It's my plan then to devote much more time to assessing and testing and refining the A/I. Good if it's a community effort.
Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
Post Reply

Return to “John Tiller's Campaign Series”