From: metro Chicago, Illinois, USA
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...
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
in the Notepad window to the upper right of this screenshot:
(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:
(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:
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
Trouble at Bir Gifgafa
0 0 0 102
0 0 0 0 7
3 0 0 0 65 75
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.
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 ...
< Message edited by berto -- 9/18/2013 5:51:36 AM >