by Crossroads | Feb 15, 2025 | Coder Diary, CSEE and Scripted AI
I have a cunning plan…

To conclude the series on Scripted AI, let us have a deeper look at how our Battle Plans for the computer opponent are generated and scripted.
First, please find links to the earlier articles here:
And now, back to those Cunning Plans.
Steps for Creating a Cunning Computer Opponent Using Scripted AI
Event Engine Lua skeleton
With csmklua.pl updated for 2.00 and 3.00 game versions, the first step is to generate a scenario-specific Lua file based on the Scenario (.scn) and Organization (.org) files.
At the time of writing, csmklua requires these files to be located in the \Scenarios root. A future update will support the new subfolder setup as well.
Let’s run this for Into Africa!, my favorite little 1973 scenario.
~/CSlint$ ./csmklua.pl -h
Usage: csmklua.pl [-h|-help] [{+|-}G|-debug] [-r[everse]] -g[ame] {me|vn|cw|ef|wf|pf} -f <scenario file> -o <lua file>
Note that the previous -a(bbpreviated), -b(locks), and -p(runed) flags are no longer required. You can still enter them, but they are enabled by default. I kept the -r(everse) option, though I can’t see a case where writing the organizations in reverse order would be useful.
The new Scenario Browser front end conveniently provides file names for all scenarios. For Into Africa!, the correct command would be:
csmklua.pl -g me -f EG_731017_Hasan.scn -o EG_731017_Hasan.lua
Here is the resulting EG_731017_Hasan.lua Lua skeleton header:

Battle Plan functions
Now that we have the Lua skeleton in place, here’s a quick recap. Among other things, it generates neat, company-sized blocks of organizations from the .org file, representing the units placed on the map. This is thanks to the now-default -p(rune) option, which removes from the Lua file any units that are not present on the map or available as reinforcements or arrivals.
Here’s a snippet of the Into Africa! Israeli organizations within the Lua file:

What we have here are mnemonics for the various units in play. For example, ALEPH_MECHANIZED_PARACHUTE_INF_COY_71_NAGMASH_116 is a mnemonic for a list that contains units 117, 118, 119, and 120.
Moving further into the Into Africa! Lua skeleton, we reach the Battle Plans section—one for each side, A and B.
Do local units = … End Blocks
What we have in the Battle Plans function at this stage is a Do local units = … End section for all formations in map.
Here’s a snippet of the Israeli Side A Battle Plan, showing how the above formations are integrated:

What the scenario designer would typically do here, for example, with the ALEPH_MECHANIZED_PARACHUTE_INF_COY_71_NAGMASH_116 company block, is assign orders to the unit as a whole. Then, since the company also includes a Heavy Machine Gun platoon, they might have the infantry platoons perform a specific task while positioning the HMG in a support role.
At this stage, however, the Middle East 3.00 Lua skeletons do not yet support manual scripting. In fact, even the full range of autogenerated options has not been fully utilized. This is simply Iteration #1, designed to quickly bring the 130+ Middle East scenarios up to speed with Event Engine integration.
Did I say 130+ scenarios? Well, that’s just the stock scenarios. Add to that the Alan R. Arvold mod scenarios, and we’re looking at another 140+ scenarios now equipped with Event Engine and Lua. Something that would have taken months and months to do manually, one by one.
But I digress. Back to what we have now with Iteration #1.
Instead of any custom code we have a call to a common set_posture(inits, side) with all units passed to it. For ALEPH_MECHANIZED_PARACHUTE_INF_COY_71_NAGMASH_116, that would be the three infantry platoons and the HMG platoon. Let us move on…
Set Posture
The idea behind the set_posture() call above is that even when using custom code, the scenario designer can leave it in place. Simply assign new orders to the units after the call. Remember, you can assign multiple orders to each individual unit in the code, but only the last order will take effect.
This is what the Set Posture function does next:

First, it obtains the mission bias for the current turn, allowing it to make informed decisions. Am I on defense? Should I attack? How aggressively? The mission bias determines the answers to these questions.
Next, it gathers a list of both friendly-owned and hostile objectives for further use.
Then, it cycles through all the units passed to it, assigning them to the appropriate recipient. In this case, we are only dealing with combat units, but we’ll take a closer look at that in a moment.
Before that, one more key function.
Set Counter Measures
Let’s examine one vital function from the Battle Plan: the Set Counter Measures function call.
Both Side A and Side B Battle Plan functions conclude with a call to Set Counter Measures, wrapping up this turn’s Cunning Plan cycle. Here it is:

At the moment, Set Counter Measures is primarily a placeholder.
In the next iteration, it will likely include generic logic, such as implementing countermeasures when an objective is lost, as the name suggests.
Handle Combatant Units
Back to Set Posture! In above picture, we also have the final Do local units = … End blocks—two artillery formations and two off-board aircraft flights.
These represent the two sections of generic Scripted AI now implemented:
- Targeting and use of Indirect Fires
- Targeting and use of Airstrikes

Let us look at both combatant type handler functions next.
Handle Indirect Fire Units
There is actually a lot going on with Indirect fire units.

This is just a snippet. Let me have ChatGPT summarize the indirect fire handler for you:
Handling Indirect Fire Units in Scripted AI
The handle_indirect_fire_unit() function is responsible for managing artillery and indirect fire assets within the Scripted AI system. It determines whether the unit should fire, how it should engage, and under what conditions it should preserve ammunition or pass control to the AI.
Key Steps in the Function:
-
Determine Unit Capabilities & Mission Context:
- Identifies the unit’s location, fire range, and mission bias (offensive or defensive).
- Checks if the unit is part of a combined force with infantry (for tactical support roles).
-
Check for Ammo Availability:
- If the unit is low on ammo, it is released to the Engine AI (EAI) instead of firing.
-
Select Target Priorities:
- Gathers friendly and enemy objectives to define potential targets.
- Builds a priority target list based on known enemy positions.
-
Execute Fire Orders:
-
If the unit is providing fire support for infantry, it cycles through targeting logic, with probabilities assigned to different actions:
- Direct fire at nearest enemy units in LOS.
- Indirect fire at high-priority targets.
- Firing at enemy positions near strategic objectives.
- Holding fire to conserve ammo (35% chance).
-
If the unit is field artillery, it follows a similar logic but prioritizes operational targets over tactical ones.
-
Final Decision Loop:
- The function repeats until a valid fire order is set, ensuring an adaptive response based on battlefield conditions.
This approach allows the AI to effectively utilize indirect fire assets, prioritizing key targets, and making realistic tactical decisions without excessive scripting. Future iterations could introduce more sophisticated counter-battery fire and response mechanics to further enhance battlefield dynamics.
^ There you go! And this is iteration #1. Maybe more cunning artillery tricks for the next iteration?
Handle Offboard Aircraft Units
Airstrikes logic is a simplified version of above. The priority target list is a tad simpler, and also there will be a maximum of one new Airstrike ordered per turn.
Here is a similar ChatGPT summary on Airstrikes:
Handling Airstrikes in Scripted AI
The handle_offboard_aircraft_unit() function manages offboard air assets, determining when and where to conduct airstrikes. Unlike indirect fire units, which follow a detailed prioritization loop, airstrikes operate on a simpler, high-impact decision process.
Key Steps in the Function:
-
Chance-Based Decision:
- Each turn, there is a 50% probability that an airstrike will be considered.
-
Identify High-Priority Targets:
- Searches for spotted enemy units that fit specific high-value target criteria, including:
- Headquarters (HQs)
- Supply units
- Indirect fire assets (artillery and mortars)
- Engineers engaged in mine-clearing, laying mines, or bridge-building
-
Execute Airstrike (if viable targets exist):
- If at least one high-priority target is found, the AI picks one at random for an airstrike.
- The system ensures only one airstrike per side per turn, preventing overuse of air assets.
Strategic Implications:
- This function limits excessive airstrike spam by enforcing a one-per-turn rule.
- It prioritizes logistics disruption and counter-battery roles, making air assets more impactful.
- Future refinements could introduce mission-based prioritization, such as focusing airstrikes on advancing enemy forces or known strongpoints.
This approach ensures that airpower remains a tactical tool rather than a blunt-force weapon, adding depth to AI decision-making.
^ There you go! Could not said it better myself.
Looking Ahead: Iteration #2
Designing, writing, and testing Iteration #1 of the Next Gen csmklua utility was great fun. I initially aimed for a more generic yet cunning and randomized logic for Battle Plans, but getting the framework in place took time.
For the next iteration, I hope to implement a Set Counter Measures system with the following principles:
- When advancing, secure a captured objective before pushing forward to the next.
- In a rearguard action, fall back to the next objective while delaying and disrupting the enemy as much as possible.
For Handle Combatant Units, the plan is to expand support for additional unit types, ensuring more comprehensive AI behavior across different formations.
-
Infantry companies should execute their missions to the best of their abilities. Now that Mission Type is available in Lua, different missions should play out accordingly—Ambush should feel distinct from Rearguard Action, and a Recon Attack should not behave like Mopping Up.
-
Support behavior must be properly implemented. Tanks should operate with dedicated logic, while the real challenge lies in handling IFVs and APCs. These units must behave logically both when loaded with infantry and after disembarkation, adapting to their role on the battlefield.
Refining these mechanics will be key to creating a more responsive and tactical AI, where support elements coordinate with combat units rather than acting independently.
Now, the Engine AI—the legacy AI—isn’t actually bad at handling individual units. It really isn’t. Expanding these behaviors will bring greater depth to Scripted AI, making engagements feel more dynamic and mission-driven.
So much to do—wish me (and us) luck!
Thank you for reading this far, and stay tuned for Vietnam 2.00.01 and Middle East 3.00.01 releases!
by Crossroads | Feb 9, 2025 | Campaign Series Legion, CS: Cold War (WIP), Gaming Surveys

With the Campaign Series: Cold War survey now open for the first 24 hours, we thought we’d share the first results right away!
Edit: The survey has closed now. Thank you! Your feedback is greatly appreciated and helps us make informed decisions about the Cold War 1.0 scope for release.
This is what you told us:
With 110 responses so far, here we go!
Security Question
From the security question, we can confidently deduce that everyone participating in the survey was able to write “Cold War” correctly—with proper capitalization and no hyphens. Excellent!
On a more serious note, thank you for your time and insights. We truly appreciate your feedback and promise to do our best to take your answers into account when making Cold War-related game design decisions.
And we’ll do our best to consider all areas without any red dots, too.
Profile – Age

While we’re not getting any younger, the survey results suggest that many of us have been following the Campaign Series games since their early days with Talonsoft. I’m right there in the most common age group as well. And yes, I also started with Talonsoft’s West Front myself.
That said, we intend to keep the Campaign Series user experience up to date, with a strong focus on graphical user interface improvements in the upcoming Summer update.
Profile – Collection

John Tiller’s Campaign Series remains the most common background among respondents, with most indicating they either own or have played the game at some stage.
It’s also great to see Middle East as the second most popular title owned. We’re especially excited to have Middle East 3.00 out now, featuring improved Scripted AI support.
As for Vietnam, there were quite a few calls for a separate Korean War game. While we don’t have plans for a standalone purchase, our vision is for CS: Vietnam to evolve into a combined CS: Korea and Vietnam title one day.
Hardware – Operating System

It’s great to see that pretty much everyone is using a modern OS. We officially support Windows 10 and 11, as they align with Microsoft’s own support policies. This survey matches the Steam Hardware Survey results, too.
With the 2.00 and 3.00 releases, one of the highlights for me personally was deprecating the old Main Menu front end, which previously required 2008 redistributables. Now, we’re fully up to date with the latest .NET framework and redistributables that Microsoft offers, ensuring a more modern and stable experience.
Hardware – Display Resolution

This was one the questions we were really interested to learn of. With previous survey, we decided on 1366*768 as our lowest common deminator. It will be HD (1980*1080) from now on.
4K is becoming more common as well. With previous survey, it presented one tenth of displays out there with our community. Now, one quarter. We appreciate Desktop scaling is becoming more and more important, and are upgrading our UI with that in mind as well, including system fonts etc.
Hardware – Number of Displays

Another interesting question! The game engine still includes several modal dialogs, which, when open, prevent interaction with the game map.
While I was perhaps expecting more players to have multi-monitor setups, the responses reinforce that removing modality and better supporting dual displays should remain a priority as we continue updating the game UI.
Hardware – RAM

With modern systems, CPU power has largely become irrelevant in terms of what the CS game engine demands from hardware. However, memory size was of particular interest, especially in understanding how many players are working with a limited RAM footprint.
One of my personal wishlist items is to move to 32-bit bitmaps with alpha channels, which would require approximately 33% more memory and disk space. Even with that change, 8GB of RAM should remain sufficient, though anything lower could become an issue.
That said, it’s reassuring to see that more than three-quarters of you have setups where RAM will not be a limitation for future versions of the game.
Game Options – Opponent

OK, on to scenario design next! Interestingly, your responses this time are quite similar to what you told us in our previous survey for CS: Vietnam. At the time, we undertook the herculean effort of integrating Scripted AI with the Lua engine, allowing it to work seamlessly alongside the game engine.
It took quite a while, but Vietnam 1.0 shipped out with a much stronger Lua companion than what Middle East 2.0 had at the time. Again, I am happy to see Middle East 3.00 now at the same engine version baseline with Vietnam.
Of course, Scripted AI also supports H2H play, and we haven’t forgotten about you H2H players at all. In fact…
Game Options – Matrix PBEM++

Last time, about one-tenth of you expressed interest in PBEM++, but now, that number has grown to one-third! With the new game front end now in place, we can finally start planning PBEM++ integration.
I have no idea yet whether the interface will be complicated or straightforward, but I’m sure the Matrix tech team will be supportive as we explore the process. Time to find out—fingers crossed!
CS: Cold War – Historical Era

The 1980s seem to be the sweet spot for Cold War games across the board, and the same holds true here. One of the key differences the Campaign Series offers, however, is our expansive timeline for Orders of Battle.
While I’m just as eager as anyone to see those Team Yankee-style battles unfold, one idea we’re exploring is to create a series of identical battles—same force size, same location—but played out across different decades.
Personally, my favorite tic-tac-toe scenarios are the Teaching Set battles from Middle East, where a small task force on each side fights for the same town, but in a different historical era each time. But I digress. Next up: scenario size!
CS: Cold War – Scenario Size

This question—and the next—reinforce what we’ve heard before: something for everyone, but with a particular focus on medium-sized formations and scenario sizes.
CS: Cold War – Scenario Length

Medium minus it is, like with a good steak, right. But we are a diverse lot, so something for everyone it is.
Of particular interest were the answers for “Week in” scenarios. We lost the Linked Campaign games for Vietnam 1.0, and to accommodate for that, Jason designed two large scenarios, or large maps and long duration, rather, where you will take your Bridgade sized unit and response to various threats in various locations during each day.
And while we are eternally the optimist to have Linked Campaigns return one day, it is the “Week in” scenarios that are there until that, and after the event too. They are great fun to those who have the time to invest for them!
CS: Cold War – “Week in…” Wish List
There was a ton of suggestions here – thank you! This is how ChatGPT summarized them:
Summary of Open-Ended Responses on “Week In…” Settings
Popular Locations & Themes
- Central Europe & Germany dominate preferences, especially:
- The Fulda Gap (heavily mentioned)
- North German Plain
- BAOR (British Army of the Rhine)
- Berlin & Denmark
- US V and VII Corps regions
- Some interest in Austria, Holland, Belgium, and Poland for NATO vs. Warsaw Pact conflicts.
- Specific mentions of US Armored Cavalry Regiments (ACR) vs. Warsaw Pact forces in delaying actions.
Other Regions of Interest
- Africa (Angola, South America) was mentioned as a potential setting.
- Some interest in hypothetical 1980s Korea and Afghanistan (USSR Invasion).
- Real-world conflicts such as Falklands, Panama, Grenada, and Russian-Afghanistan War were suggested.
Scenario Design & AI Expectations
- Some respondents haven’t played “Week In…” scenarios yet but are interested in trying them.
- Requests for specific unit-focused battles, like 11th ACR in Fulda Gap.
- Some players would like customizable “Week In…” options, allowing for flexibility.
- AI scripting should be driven by easy-to-set objective parameters to allow for better AI movement control.
Gameplay Mechanics Suggestions
- Interest in supply mechanics, including scenarios where cut-off units rely on air-dropped supplies.
- Defensive and counter-attack operations in West Germany were mentioned, with specific references to WMD scenarios, river crossings, and mobile warfare.
- Some players prefer historical accuracy, while others are open to hypothetical scenarios.
General Sentiment
- Many respondents are unsure about their preferences but are open to trying different settings.
- Some just enjoy the game mode regardless of location, expressing “no preference”.
CS: Cold War – Orders of Battle

Next, we’re firmly in the territory of when Cold War 1.0 will be considered ready for release.
Each nation and its Order of Battle requires quite an effort to develop. We’re easily looking at two to three months per nation, at a very minimum, given the level of detail and accuracy we strive for.
It was particularly interesting to learn that around 40% of you would be happy with what’s already close to completion: The US, UK, and France versus the Soviet Union, Poland, and Czechoslovakia. However, half of you said you’d be willing to wait longer to have West Germany included as well. And of course, there were great shouts for other nations, too—a strong indication of just how much depth and variety this game can offer!
CS: Cold War – Maps

While the previous responses gave us some leeway to ship with the nations we already have, the message here was clear—Fulda Gap alone won’t cut it.
Jason, as a professional cartographer—get your period maps ready! The audience wants more!
Creating master maps takes time, and between this question and the previous ones, your message was loud and clear.
CS: Cold War – Scripted AI

The scope of what Lua and Scripted AI offer for Campaign Series scenario designers is quite unique among wargames, and it was great to see that this effort has been appreciated as well.
While proper Lua events—the Green sector here—demand a lot from the scenario designer, we’re experimenting with a Lua skeleton makefile that will automate as much event and battle AI logic as possible.
This way, scenario designers won’t need to worry about the basics and can instead focus on crafting devious battle AI and event-driven scenario endgames.
CS: Cold War – NBC

Many of my favorite Cold War books, such as Chieftains, end with that ominous mushroom cloud in the sky. Others call a halt to hostilities before reaching that point. It wouldn’t be prudent to design a Cold War game without asking this question, right?
Based on your responses, about two-thirds of you prefer to have NBC weapon systems in the game, while some of you want nothing to do with them. And some of you absolutely want them. This is just a game.
Some Cold War-era weapon systems, especially those introduced later, aren’t yet supported by the game engine—such as scatterable minefields. Implementing these will open the door to other battlefield-affecting systems. At this stage, we’re likely to take a middle-ground approach, prioritizing scatterable mine munitions first. If time allows, maybe more.
Additionally, I believe there should be a scenario tag in the Scenario Browser, informing players if NBC weapons are present in a scenario. That way, players who prefer to opt out can do so easily.
CS: Cold War – Floor Is Yours!
Again, thank you so much for taking the time to complete this survey and for all your insight and suggestions! Below is a ChatGPT-generated summary of all the open-text responses to this question. Rest assured, we are also reading every individual response to ensure we capture all your feedback.
(Note: As I mentioned earlier, the Korean War is likely to be included in a future update for CS: Vietnam, effectively transforming it into CS: Korea and Vietnam over time. To be determined!)
Summary of Open-Ended Responses – CS: Cold War
General Excitement & Support
- Many players appreciate the continued development of the Campaign Series and are excited about Cold War.
- Some are eager for an early release, even if content is expanded later through DLCs or updates.
- A few mentioned their willingness to financially support the game’s development through purchases.
- Several long-time players (since East Front and West Front) expressed gratitude for the effort put into the series.
Preferred Nations & Order of Battle (OOB) Priorities
- West Germany is the top-requested addition for initial release.
- Canada was often mentioned as the next priority.
- East Germany is considered important but secondary to West Germany and Canada.
- Some players want smaller nations and proxy war participants included in future updates (e.g., Scandinavia, Balkans, Korea, and Middle Eastern forces).
Geographical Scope & Scenario Focus
- Cold War conflicts outside of Europe are highly requested:
- Korea (1950-1953 and hypothetical 1980s scenarios) was one of the most frequently mentioned settings.
- Africa, Central America, South America, and the Middle East were also requested.
- Arctic and Scandinavian scenarios, as well as NATO vs. Warsaw Pact engagements in Austria and Finland, were suggested.
- A modular DLC approach was proposed, with content grouped by geographical and climatic regions (e.g., Germany North/Baltic, Central Europe, Mediterranean, Arctic).
Gameplay & Features Requests
- Scripted AI improvements and better AI behavior are crucial for many players.
- Some requested more intelligent AI with adaptable objectives.
- Linked Campaigns remain a highly desired feature.
- Some players want a more flexible, DIY scenario builder with better tools for creating custom scenarios.
- Team play (2v2 or more) is a popular request.
- Special forces operations and unconventional warfare would be a welcome addition.
- Intel from captured enemy units could add strategic depth.
- Expanded air units and missions were suggested for added realism.
Cold War Equipment & Mechanics
- Chemical weapons should be included at launch, while nuclear weapons could wait for a later update.
- Scatterable minefields and better supply mechanics are key features players want to see.
- Sound design improvements were emphasized—tanks and weapons should sound authentic for immersion.
Long-Term Direction & Other Conflicts
- Some players feel the Cold War era is oversaturated and would prefer a return to pre-1945 Eastern and Western Front games.
- Korean War (both 1950-53 and later hypothetical scenarios) is one of the most requested future projects.
- Future scenarios covering conflicts up to 1991 (including Desert Storm) were suggested.
- Interest in fictional and literary-inspired battles (Team Yankee, Red Storm Rising).
- Some would like future modern scenarios (2020+) to explore contemporary conflicts and geopolitical tensions.
Concerns & Critical Feedback
- Some players feel the engine is aging and could benefit from modernization.
- A few are frustrated with the lack of updates on promised East Front III.
- There’s a desire for more accessibility in scenario design, making it easier for players to create custom content.
Final Thoughts
- Overall, strong support for the project, with a significant demand for:
- Expanding beyond Europe
- Better AI & automation tools for scenario design
- More playable nations and detailed OOBs
- Authentic Cold War weapon systems and mechanics
- Many players trust the team’s vision and are excited for what’s to come.
THANK YOU!
With best regards,
– Campaign Series Legion