Latest topics
» Impromptu Games
by Morsey Sun Oct 14, 2018 4:02 pm

» Presentation
by Uncle Billy Wed Oct 10, 2018 6:54 pm

» DarkRob's Video of the KS Napoleon Mod
by Uncle Billy Mon Oct 08, 2018 4:43 pm

» Set Up for SOW ACW GAMES For Kriegspiel style
by Uncle Billy Fri Oct 05, 2018 4:55 pm

» September 23rd 2018 face to face game at Little Gaddesdon
by henridecat Wed Sep 26, 2018 8:21 pm

» November 25th 2018 face to face game at Little Gaddesdon
by Mr. Digby Wed Sep 26, 2018 5:55 pm

» October 21st face to face game at Little Gaddesdon
by gunboat diplomat Wed Sep 26, 2018 4:49 pm

» Autumn schedule of face to face games at Little Gaddesdon
by gunboat diplomat Mon Sep 10, 2018 4:49 pm

» 1828 dice tables
by Tim Carne Sat Aug 25, 2018 2:42 pm

» Kriegsspiel revised rules 1828
by Tim Carne Thu Aug 23, 2018 3:32 pm

» Other PC games - Command Ops 2
by Martin Thu Aug 16, 2018 5:58 pm

» Other PC games - Campaigns on the Danube
by Martin Wed Aug 15, 2018 5:11 pm

Statistics
We have 1030 registered users
The newest registered user is afcwfan

Our users have posted a total of 25143 messages in 1991 subjects
Log in

I forgot my password


Deciphering the AI system

Page 1 of 2 1, 2  Next

Go down

Deciphering the AI system

Post  Didz on Thu Apr 19, 2018 3:38 pm

This is an extension of a debate which has been raging for some time on the Steam Forum, without really making a lot of progress. What I'm hoping to do is add a bit more understanding of how the AI system in SOWWL works to the .pdf and video already produced by Mitra. (see Links below)
[video width=425 height=344 type=youtube]https://youtu.[/video]
http://www.norbsoftdev.net/forum/waterloo-media-section/71178-ai-tutorial#71184

What I'm looking for are people who are interested in gaining a better understanding of how the current AI system works, and/or, have the skills necessary to decipher some of the coding used by the game to manage the AI behaviour.

Mitra has already defined the four key components of the AI system as:

1. Stance
2. Divisional Strategy
3. Tactics
4. Take command

'Tactic's' and 'Take Command' seem pretty clear as Mitra says that the only Tactic available to the player is the ability to set a 'Tactical Destination'. So, basically the 'Move to' command issued via the Command Map, Mouse Pointer or Courier Message. The AI is then bound by that instruction to try and move to that destination.

Likewise 'Take Command' is described by Mitra as turning the AI Off, so as far as I can see it's just an On/Off switch, and once it's off the AI plays no further part in a units behaviour. Although, there may still be some involvement of the AI in a units close combat reactions and so there may be some detail to explore as to what impact 'Take Command' has at battalion; Regiment and Battery level.

However, the real guts of the AI system seems to be driven by the Stance Table and the Divisional Strategy options that are linked to it. Mitra's refers to the later as Schema's, or Tactical Schema's, and the AI appears to select for the 60 schema's available according to the Stance selected by the player, or the AI commander, and the 'Style' of the commander (which I think means his personality). I assume that Aggressive commanders are more likely to select aggressive tactical schema's.

If anyone is interested in helping me unravel these mysteries please post below.
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Fri Apr 20, 2018 1:56 am

The stock AI has a number of shortcomings.  It is largely based on the SOWGB game AI with squares and a bit of cavalry and skirmisher logic added.  As a consequence, it doesn't really reflect European warfare of the early 19th century.  In order to have the AI perform in that style, heavily scripted scenarios must be written.  I've rewritten most of the AI code to make it perform in a more 'Napoleonic' style without any scripting, (sandbox mode).

It's been a long while since I've looked at the original code, so some of what I say below may be more of a description of the KS mod than the stock game.
the only Tactic available to the player is the ability to set a 'Tactical Destination'. So, basically the 'Move to' command issued via the Command Map, Mouse Pointer or Courier Message. The AI is then bound by that instruction to try and move to that destination.

Yes and no.  It depends on the level that the player chooses to command.
At the brigade level, the battalions have no strategy.  They will respond to threats, but they rely on the player to give them locations to move to, formations to assume, etc.
At the division level, brigades must be given a stance if they are to do anything useful.  This will activate them such that they will turn as a unit and face an approaching, flanking enemy, engage the enemy when they reach varying distances, determine which formation to use while fighting, how many skirmish units to send out and how many battalions to leave in reserve.  The brigade AI will also give the battalions destinations when advancing towards the enemy.
At the corps level, the division at will give stances to the brigade commanders, decide on how many should be in reserve, decide when to use those reserves, if at all, and where to send them.  It will also give them a general destination when attacking the enemy.
At the army level, the corps AI will give the divisions a stance, and destination.  It will keep reserves and send them to unit(s) requesting help.  It is fairly simplistic.

Likewise 'Take Command' is described by Mitra as turning the AI Off, so as far as I can see it's just an On/Off switch, and once it's off the AI plays no further part in a units behaviour. Although, there may still be some involvement of the AI in a units close combat reactions and so there may be some detail to explore as to what impact 'Take Command' has at battalion; Regiment and Battery level.

TCing a unit turns it into a zombie.  Battalions will fire on units that come into range and will charge if an enemy unit gets very close.  It will not change formation or the direction it faces.  TC'd officers will not give any orders and battalions will not ask for any direction from one.

However, the real guts of the AI system seems to be driven by the Stance Table and the Divisional Strategy options that are linked to it.

Only to a limited extent.  Most of the AI behavior is governed by a rule-based system, (if these conditions are met, then do this).  Stances and divisional strategies only mildly influence these rules.

Mitra's refers to the later as Schema's, or Tactical Schema's, and the AI appears to select for the 60 schema's available according to the Stance selected by the player, or the AI commander, and the 'Style' of the commander (which I think means his personality). I assume that Aggressive commanders are more likely to select aggressive tactical schema's

The battle strategy selection is very much random.  It is somewhat weighted by the division commanders personality, but this is a minor influence.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Fri Apr 20, 2018 1:45 pm

Thanks Uncle,

I suspected that the Waterloo AI code would have been borrowed and modified from the Gettysburg game, and as you rightly say that will have created a number of issues, as contrary to the current propaganda published by US historians the ACW was not an extension of European Warfare and tactic's, and unit behaviour under fire was completely different.  Not least because of the preponderance of rifled weapons and the tendency for soldiers to actually aim at each other.  So, I suspect that the code which was tested for Gettysburg is going to create issues for Waterloo.  I've never played SOWG so I can't compare directly, but you can see similarities in unit behaviour to tactical descriptions of the ACW, and as you say it doesn't look quite right sometimes for European warfare.

I remember the Avalon Hill Magazine publishing an excellent article on ACW tactical behaviour and it differed from European warfare, even the nature of the terrain over which the battles were fought varied considerably and influenced the tactic's considerably.  Unfortunately, we live in an age where the USA is seeking excuses to vindicate the actions of its past and so there is a constant pressure to blame the influence of Prussian Drill methods on the death toll inflicted on the battlefields of North America.  So, you constantly see historians claiming the tactic's employed were identical or similar.  
Uncle Billy wrote:At the brigade level, the battalions have no strategy.
I sort of assumed that as the Brigade is the lowest level in the command chain.  Although you can allocate it a separate 'Tactical Destination'  as I assume can its AI Divisional Commander.

There were questions asked as to whether an AI Divisional Commander can override and change the orders issued directly to one of his Brigades by the player, and so far I've seen two completely different answers to that question.  

Mitra on the Norbsoft forum seems to say 'No', he can't, once the player has interfered directly in the deployment of a brigade then that brigades orders cannot be changed by the AI.

However, when I asked a similar question on the steam forum I was told of course it can, and not only that but the AI can dynamically change its own orders from the player without even informing the player it has done so.

Coding wise there must be a right answer to that question, but gameplay wise I'm not sure which approach makes more sense.
Uncle Billy wrote:TCing a unit turns it into a zombie.  Battalions will fire on units that come into range and will charge if an enemy unit gets very close.  It will not change formation or the direction it faces.  TC'd officers will not give any orders and battalions will not ask for any direction from one.
That seems pretty clear, and it's been the consistent message throughout.  Which is why the AI becomes so much more important when playing at higher command levels.
Uncle Billy wrote:Only to a limited extent.  Most of the AI behavior is governed by a rule-based system, (if these conditions are met, then do this).  Stances and divisional strategies only mildly influence these rules.
That's actually quite worrying.  Because assuming your right then what your saying is the player who uses the AI command system can only 'mildly influence' the course of the game.

It isn't the impression I got watching Mitra's video, which seems to suggest that using the right stances and divisional strategies can make a significant difference to AI behaviour.
Uncle Billy wrote:The battle strategy selection is very much random.  It is somewhat weighted by the division commanders personality, but this is a minor influence.
I haven't yet fully grasped what these schema's are and how they work.  

Hook on the Steam Forum believes that they are little more than a pattern for the mix of Brigade Stances issued by an AI Divisional Commander to his sub-units, but my original impression was that they were more like a tactical formation template for how that AI Divisional Commander deployed his brigades.  e.g. Will he keep a reserve?, will he order an all out assault?,  will he refuse his flank? will he detach skirmishers? etc.

Likewise Mitra suggests that the choice of schema's available are influenced by the players choice of stance and the commanders 'style'.  More aggressive stances and personalities being more likely to result in an aggressive choice of schema.  But that seems unlikely of the AI behaviour is simply governed by hard-coded reactions to rules triggers.  That sounds more like the system used by Creative Assembly, where certain units are hard coded to seek your flank, and to react by withdrawing as soon as the player switches to canister shot on his artillery.  I can't say I've noticed that sort of instant reaction by the AI in SOWWL, but it might just be a bit more subtle.
+++++
Whilst on the subject of Tactical Schema's, I was studying the Stance Table last night and trying to determine what all the variables mean't and plotting them to a spreadsheet.

Amid all the variables related to Morale and Distances I noticed that Var#35 is labelled 'BrigForm', which I assume is short for Brigade Formation and has values in the format of 'eFTFight' etc. Do you know if these are links to Tactical Schema's?
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Fri Apr 20, 2018 5:26 pm

There were questions asked as to whether an AI Divisional Commander can override and change the orders issued directly to one of his Brigades by the player, and so far I've seen two completely different answers to that question.

The SOW AI strictly follows the chain of command.  If you are a division commander, then the AI corps commander will not change any orders you give to your brigades.  However, the AI brigade commander reserves the right to modify it if he see a bigger threat or is already heavily engaged.  If you give a brigade an order as a corps commander, violating the chain of command, the AI division commander can override it whenever he sees fit.

That's actually quite worrying.  Because assuming your right then what your saying is the player who uses the AI command system can only 'mildly influence' the course of the game.
It isn't the impression I got watching Mitra's video, which seems to suggest that using the right stances and divisional strategies can make a significant difference to AI behaviour.

Stances are important in that they tell the AI subordinates how aggressive to be.  This influences their decisions on how many units to engage the enemy with, how close the enemy needs to be before launching an attack and in disengaging.  But how brigades and battalions actually fight the battle is a function of the coded rule set.  To give a simple example, when a battalion sights a cavalry regiment approaching, it will ask the brigade commander if it should form a square.  Part of the decision is based on the brigade stance.  The more aggressive the stance, the closer the cavalry is allowed to approach, (The KS mod also takes into account the battalion's experience and adds a random factor in).  If the brigade commander is TC'd or has no stance or is a human, then the battalion will resort to a default procedure to make the determination.  Regardless of stance, the battalion will not form a square if it is actively engaged with the enemy or its morale is too low.

Hook on the Steam Forum believes that they are little more than a pattern for the mix of Brigade Stances issued by an AI Divisional Commander to his sub-units, but my original impression was that they were more like a tactical formation template for how that AI Divisional Commander deployed his brigades.  e.g. Will he keep a reserve?, will he order an all out assault?,  will he refuse his flank? will he detach skirmishers? etc.
They are both.  The division strategy sets the aggressiveness of the individual brigades and batteries.  This in turn helps determine what units will move forward to attack and which stay in place as a reserve.

Likewise Mitra suggests that the choice of schema's available are influenced by the players choice of stance and the commanders 'style'.  More aggressive stances and personalities being more likely to result in an aggressive choice of schema.
This part of the code is not available to us, but based on my experience, this is not the case.  It may be that this is what is intended but that part of the code is broken.  There were numerous pieces of the dll code that were contradictory or unreachable.

Amid all the variables related to Morale and Distances I noticed that Var#35 is labelled 'BrigForm', which I assume is short for Brigade Formation and has values in the format of 'eFTFight' etc. Do you know if these are links to Tactical Schema's?
Formations such as 'eFTFight' refer to formation specified in unitglobal.csv for the various unit classes.  The formations specified in that csv file are heavily used in the dll code and not subject to the tactics table.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Sat Apr 21, 2018 11:55 am

Thanks for the reply.

I noticed your comment about the AI following strict order of command rules about overriding orders.  However, that appears to conflict with Mitra's explanation on Norbsoft forum several years ago when he was asked the same question.
mitra76 wrote:
1. What is the relationship of the division commander's stance if you set another stance for one or more of his brigades? E.g. division commander stance is "Hold to the Last" and you set one or more of his brigades to "All out Attack"? What is the effect of this? Will the AI division commander "override" (or attempt to) the human players stance selection for one or more of the brigades (i.e. back to "Hold" or "Hold to the Last" depending on characteristics)? Is there an advantage to setting different stances for your brigades than those set for the division commander?

The stance of division commander is part of division deployment schema determination (more aggressive, more aggressive schema) which determine also the brigade stances, so a division officer with aggressive stance has more chances to have aggressive brigade commanders but is not a rule, there're many factors involved. Division commanders with hold to the last never determine a schema, so it is the correct stance in order to have the division under more strict control.

The stance set from the players are not changed, but anyway (a part for the case of hold to the last and all out attack) the brigade officers can change them in autonomy in particular situations, like a change of destination given from the player.

2. A Division commander has "No Stance" or "Neutral" - same for his Brigades. When the Division comes into contact with the enemy, will the Division commander attempt change his stance depending on his characteristics, i.e. change himself and/or one or more of his brigades from "Neutral" to "Defend"?

Division commanders don't acquire stance automatically when engage only brigade commanders do; anyway also neutral schema permits the division schema determination (and stances for the brigades as described above)
In Mitra's reply he gives the clear indication that an AI Divisional Commander will NOT override a stance set for a brigade by the player. (see highlighted text above)

Stances are important in that they tell the AI subordinates how aggressive to be.....
I'd gathered that from watching Mitra's video.

In fact, to be honest it was this video that re-kindled my interest in the game, as after the initial disappointment of realising that the so-called Campaign was nothing like a campaign mode for 1815 I had struggled to cope with the games poor representation of Napoleonic tactic's and inaccurate battlefield maps and eventually shelved it as another waste of my money before moving on to other things.  Mitra's video actually got my attention because it seemed to suggest that there was at least an element of strategy associated with the way one instructed the AI to fight the battle.  I became quite intrigued as to how 'Stances' made a difference to the AI behaviour and perhaps provided a key to success of failure in different situations.

However, I was also frustrated by the lack on information provided by Mitra as to how that worked.  He mentions things like differences on reaction ranges etc. without providing a table of what they are or how they differ for example.  So, by accident or design the whole AI system is shrouded in mystery that nobody seems to understand, and most people seem to just switch it OFF and TC everything anyway.  So, when I began to ask questions to try and explore this new (for me) feature of the game I found there weren't any answers.

Also, Hook on the Steam forum is adamant that the Stance chosen by the player can and will be over-ridden by the AI, pretty much at the drop of a hat.
LHookins wrote:At any point the individual commander may modify his ordered stance based on his own abilities and aggressiveness, and issuing perhaps modified stances to subordinates, who will then do the same all down the line.
Which seems to conflict with your strict rule of command statement, and if it happens without proper notification to the player would render a players ability to play the game using the AI futile.

Personally, I have no problem with the AI choosing to ignore or change my orders.  In fact, in many ways it makes the game more realistic if your AI sub-ordinates are less than 100% compliant with your wishes.  However, I would expect such insubordination to at least be justified by the AI, and to be notified by the AI commander concerned that he could not comply with his orders.  You can see that if the AI really does what Hook suggests, and fails to inform the player, then attempting to play the game using the AI becomes pointless.  This is basically what killed off the Peter Turcan games and why most players turned the AI off when playing them.  e.g. pretty much as we do when we TC everything to play.
Uncle Billy wrote:
Didz wrote:Likewise Mitra suggests that the choice of schema's available are influenced by the players choice of stance and the commanders 'style'.  More aggressive stances and personalities being more likely to result in an aggressive choice of schema.
This part of the code is not available to us, but based on my experience, this is not the case.  It may be that this is what is intended but that part of the code is broken.  There were numerous pieces of the dll code that were contradictory or unreachable.
From what I've understood of the Stance Table so far the current Stance assigned to an AI commander has a number of variables associated with it, many of which are Morale related

e.g. / 5 Fallback (at morale level:) and / 13 Charge (Morale)
So, if a Stance is being consulted by the AI system it ought to adjust the likelihood of a unit performing certain actions, as Mitra suggests.

It also lists a number of variables that are distance related.
e.g. /21 SquareToEnemy; //minimal distance from the enemy to go in and out from a square formation  and /22 CavChargDist;  //minimal distance of charge's start

Again if these distances are included as part of the AI system they would have an impact on how effectively a unit in that stance reacts to a situation.  So, assuming the stance table is referenced it should have a noticeable impact on the behaviour of the units to which it is applicable.  How much that influence is subject to random chance I'm not sure about, but it shouldn't be so random as to make the choice of stance irrelevant.

However, I get your point about the Tactical Schema's being beyond reach, although Mitra seemed to understand them.  It would certainly be useful to understand at least what they did,(if anything).  In fact, from a modding point of view I would imagine they might be quite useful in correcting some of the tactical issues in the game.


Last edited by Didz on Sun Apr 22, 2018 12:42 pm; edited 8 times in total (Reason for editing : Contracting a reply.)
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Sat Apr 21, 2018 4:42 pm

In Mitra's reply he gives the clear indication that an AI Divisional Commander will NOT override a stance set for a brigade by the player.
He's wrong. It happens frequently.

Also, Hook on the Steam forum is adamant that the Stance chosen by the player can and will be over-ridden by the AI, pretty much at the drop of a hat.
As I said in the previous post, it only happens if the player bypasses the chain of command.

Mitra's video actually got my attention because it seemed to suggest that there was at least an element of strategy associated with the way one instructed the AI to fight the battle. I became quite intrigued as to how 'Stances' made a difference to the AI behaviour and perhaps provided a key to success of failure in different situations.

However, I was also frustrated by the lack on information provided by Mitra as to how that worked. He mentions things like differences on reaction ranges etc. without providing a table of what they are or how they differ for example. So, by accident or design the whole AI system is shrouded in mystery that nobody seems to understand, and most people seem to just switch it OFF and TC everything anyway. So, when I began to ask questions to try and explore this new (for me) feature of the game I found there weren't any answers.

Stances do make a difference and indeed can decide success and failure, but not for the reasons you are thinking. Stances influence when certain actions occur. The rules embedded in the AI determine what actions can occur. From the player's perspective, this looks as if the units are more of less aggressive/reckless. At it's core, the AI's primary purpose is to put units within firing range of each other without regard to anything else. The AI rules retard that primary purpose.

The shortcoming of the stock game is that the rules do not reflect warfare of the early 19th century, which was primarily concerned with command and control. The KS mod significantly improves the game in this area.

However, I get your point about the Tactical Schema's being beyond reach, although Mitra seemed to understand them. It would certainly be useful to understand at least what they did,(if anything). In fact, from a modding point of view I would imagine they might be quite useful in correcting some of the tactical issues in the game.

Indeed, it would be very nice if we had access to this part of the AI. It would make modding the AI behavior very much easier.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Sun Apr 22, 2018 1:06 pm

Uncle billy wrote:
Didz wrote:Also, Hook on the Steam forum is adamant that the Stance chosen by the player can and will be over-ridden by the AI, pretty much at the drop of a hat.
As I said in the previous post, it only happens if the player bypasses the chain of command.
Well that's slightly different.  Unless one has detached a Brigade from the command of an AI Division Commander it makes sense that any order issued by the player to that AI Division Command would of necessity override an earlier command issued directly to one of his Brigades.  

I'm assuming of course that if a Brigade has been detached then it no longer forms part of it's Division and from that point on is operating outside the chain of command.

However, the impression I was given by Hook is that the AI Division Commander himself can change the orders given directly to him by the player.  Which to be fair is what used to happen in the Dr. Peter Turcan games, and is not completely unrealistic as long as the player is informed and the AI action is justified to them by the system.

So, as I said to Hook I would have no issue if during the D'Erlon Attacks scenario I got a message from Quiot informing me that his Division had encountered major opposition trying to assault the central crossroads and that he had decided to switch his Divisions stance from 'Attack' to 'Defend' and hold his position south of the crossroads until I provided him with more support.  

In fact, in many ways that sort of dialogue and feedback from the AI would be game enhancing.  What I'm not so happy about is the idea that the AI might arbitrarily chose to change my orders without even telling me that it has done so, why it did it, and what it's proposing to do instead.  That would create an annoying chaos in a large HITS game, as indeed it did in the Turcan games. I mean I used to get in the habit cockpit style monitoring and resending or orders in the Turcan game simply because of the random habit of the AI in ignoring or changing them.

Uncle Billy wrote:Stances do make a difference and indeed can decide success and failure, but not for the reasons you are thinking. Stances influence when certain actions occur. The rules embedded in the AI determine what actions can occur. From the player's perspective, this looks as if the units are more of less aggressive/reckless. At it's core, the AI's primary purpose is to put units within firing range of each other without regard to anything else. The AI rules retard that primary purpose.

The shortcoming of the stock game is that the rules do not reflect warfare of the early 19th century, which was primarily concerned with command and control. The KS mod significantly improves the game in this area.
I think I understood that from Mitra's video tutorials.  Unfortunately, what Mitra doesn't do is provide the information in tabular form showing what impact each Stance has on the AI behaviour.

So, you get snippets of information such as 'Brigades in 'Hold to the Last' will not deploy skirmishers, and will recall those that have been deployed, and that they will not deploy to face a flank attack until it closes with them.  But there is no comparison that then says what happens if they are in 'Defend' stance instead.  He also says troops in 'All Out Attack Stance' will ignore the threat of cavalry and are less likely to form square, but without stating the actual reaction distances involved for comparison with other stances, or stating what the percentile risk is of the infantry panicking compared to when they are in a more defencive stance.

I know you've done a lot of work with the Kriegspiel Mod to improve the gameplay and make it more realistic, but in doing that did you manage to decipher any of the data that explains how the vanilla system works in order to understand and improve it?


Last edited by Didz on Sun Apr 22, 2018 1:13 pm; edited 1 time in total (Reason for editing : Typo/grammer correction)
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Sun Apr 22, 2018 3:50 pm

I know you've done a lot of work with the Kriegspiel Mod to improve the gameplay and make it more realistic, but in doing that did you manage to decipher any of the data that explains how the vanilla system works in order to understand and improve it?
Yes, of course. As I said, I rewrote most of the AI code. That can't be done without figuring out the original. It wasn't always an easy task.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Mon Apr 23, 2018 1:17 pm

uncle billy wrote:I know you've done a lot of work with the Kriegspiel Mod to improve the gameplay and make it more realistic, but in doing that did you manage to decipher any of the data that explains how the vanilla system works in order to understand and improve it?

Yes, of course. As I said, I rewrote most of the AI code. That can't be done without figuring out the original. It wasn't always an easy task.
So how difficult would it be for you to come up with a table that lists all the Stances and how they affect the behaviour of the AI in the game?

For example Mitra mentions reaction distances being multiples of engagement distances on a scale from 2 to 6 when moving, or 3 to 5 when stationary but doesn't say how they vary from stance to stance, which I assume must be coded somewhere.

Likewise, things like the percentile chance of a unit successfully forming square when charged by cavalry in various stances. Plus other probability based behaviours like launching a column assault or deploying skirmishers are mentioned by Mitra without actually recording the variances between stances.

And we are given no idea what the the 60 x schema's are or which become available in which stances.

I've been told elsewhere that the programme code is just too complex and difficult to follow to allow these things to be documented accurately. But I'm assuming that you must have managed it.
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Mon Apr 23, 2018 4:58 pm

The numbers themselves won't do you much good as distances can't be measured in the game. For example, in the stock game, the minimum distance to form a square varies from 70yd at hold at all costs to 46yd for all out attack. That's a difference of 24yd.

A number that is useful to know is the number of skirmish units a brigade can send out. For hold and hold at all costs it's 0, for defend it is 2 for probe it's 4, for attack and all out attack it's 6.

Engagement distance multiples of the max weapon range vary from 1, (moving), 1, (stationary) for hold and hold at all costs, 1.1 & 1.5 for defend, 2.3 & 4.1 for probe, 2.6 & 4.8 for attack and 2.6 & 5.3 for all out attack.

You can find all this information in the SDK in a file named xtables.inl in the TableStance array.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  risorgimento59 on Mon Apr 23, 2018 5:24 pm

Didz wrote:I've been told elsewhere that the programme code is just too complex and difficult to follow to allow these things to be documented accurately. But I'm assuming that you must have managed it.

Sorry for the intrusion.
But I though to have said something slighly different to Didz, so I'm better trying to reformulate the concept. Wink
The problem is not "documenting".
Certainly there're some parts out of the DLL source code, but that's not the point.
From my understanding, Didz was asking for something along the lines of a tabular relation between the stance table data and the resulting behaviour of units.
This isn't the way you'd normally work with non-elementary AI code.
It's quite a different beast from an humanly-rolled wargame.
AI coding's nature would marry better with an huge hierarchical flow graph, perhaps, at best (think how would you lay down influence mapping's cells spreading process? "luckily" it's not SOW's case Razz ).
Which one could consider worth to sketch out too, but imho you should not for the limited benefits you'll get.
But I'm talking from a programming-wise angle of course, when you don't need an all encompassing picture to understand AI things.
Quite the opposite. Mentally it'd go out of hand pretty soon.
You could have better luck isolating parts in more or less predictable modules and highlighing the relations between them, imho.
Excel vs Visual Studio + Visio basically. Cool
xtables has data already arranged in tabular form, though.
Excuse me again and keep up the interesting discussion. Smile

risorgimento59

Posts : 20
Join date : 2015-06-19

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Mon Apr 23, 2018 10:08 pm

From my understanding, Didz was asking for something along the lines of a tabular relation between the stance table data and the resulting behaviour of units.
This isn't the way you'd normally work with non-elementary AI code.
It's quite a different beast from an humanly-rolled wargame.

I think this may indeed be the difficulty. The AI does perform in accordance to a large set of rules, but those rules can and do overlap and influence one another. There are no dice-roll tables that determine, for example, whether an advance leads to a successful melee. That is no more true here as in a real battle.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Tue Apr 24, 2018 6:11 pm

Uncle Billy wrote:
From my understanding, Didz was asking for something along the lines of a tabular relation between the stance table data and the resulting behaviour of units.
This isn't the way you'd normally work with non-elementary AI code.
It's quite a different beast from an humanly-rolled wargame.


I think this may indeed be the difficulty. The AI does perform in accordance to a large set of rules, but those rules can and do overlap and influence one another. There are no dice-roll tables that determine, for example, whether an advance leads to a successful melee. That is no more true here as in a real battle.
Well to be fair I'm coming from the limited understanding that I gained from watching Mitra's video 'How To Use the AI in Scourge of War Waterloo', which clearly suggests that the players choice of stance has a direct impact on unit behaviour.  It was therefore, pretty logical to begin by asking the question How?

However, I'm beginning to wonder what stances are for, if not for that purpose, and even then whether they are a good idea in a Napoleonic strategy game.  The only real place I've come across stances in the past is in fantasy roleplaying games where your choice of stance gives your character various buff's and penalties dependant upon whether your stance is defensive or aggressive.

That kind of makes sense in a roleplaying game as you are in effect second guessing your opponents actions and trying to anticipate your characters needs to give it an advantage.  But it really doesn't make a lot of sense in the context of Napoleonic tactic's where reactions were largely dictated by accepted tactical doctrines and drills.  Perhaps the game would benefit simply by removing stances completely and basing unit reactions on the accepted tactic's for the period. Something that the WRG tabletop rules did really well. If one wanted to get a bit more complicated then perhaps a system that adjusted the tactical reactions of units according to their nationality would make more sense than an arbitrary stance selection.

However, I'm still trying to work out what the AI really does, as at the moment everyone is coming up with different answers.  So, trying to plot them is proving difficult.
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Tue Apr 24, 2018 11:45 pm

As I dimly recall, using stances in the stock game did not differentiate the unit behavior all that much, apart from the reaction distance, that is. With the KS mod it is a requirement to use them thoughtfully.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Wed Apr 25, 2018 2:26 pm

Uncle Billy wrote:As I dimly recall, using stances in the stock game did not differentiate the unit behavior all that much, apart from the reaction distance, that is. With the KS mod it is a requirement to use them thoughtfully.
I started off using the KS Mod as it was a prerequisite of participating in the multiplayer games organised elsewhere on this forum.  In fact, I was responsible for consolidating and transferring the KS Mod installation guidance over to Steam.

However, when I started trying to work out how to use the AI effectively i found that all the guides were using a more up to date version of the Expanded Grog Toolbar and in order to get it to work in my game i was forced to disable the KS Mod.  It also sounds as though I would have had to disable it anyway as I don;t think any of the guides I've watched or read discribe how the AI functions with it activated.

I've actually started a Steam Community Guide to record how the AI works, but soon realised that trying to map Mitra's data just raised more questions than it answered.  Hence the purpose of this thread.

As far as reaction distances are concerned the impression I got from 'How to use the AI' is that the terms Reaction Distance and Engagement Distance are synonymous and mitra seems to use them interchangeably. He states on slide 11 that 'The reaction distance is variable and different if the brigade is in movement or standing. His base is always the targeting range of the subunits of brigade (150 yds for infantry, 300 for cavalry, 1500-1800 for artillery)'.  This is then modified by the multiplier applicable to the brigades stance and whether it is moving or stationary.  The minimum would seem to be 300 yards for infantry for brigades that are moving whilst in 'Hold to the Last Stance' rising to 1,800 yards for a Brigade moving in 'All Out Attack' stance.

Presumably a commanders eyesight improves substantially when ordered to move and attack Laughing
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Dr Ezra Sidran on Wed May 02, 2018 3:59 pm

I must confess that I bought SOW Waterloo and gave up on it pretty quickly. It didn't do much for me.

But, as far as the AI goes: I suspect that it's a very simple script system, or table look-up, with absolutely no analysis whatsoever.

Dr Ezra Sidran

Posts : 87
Join date : 2016-06-10

http://general-staff.com/

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Wed May 02, 2018 5:28 pm

But, as far as the AI goes: I suspect that it's a very simple script system, or table look-up, with absolutely no analysis whatsoever.

No, that's not correct. The AI is a fairly complex rule-based system, at least at the battalion and brigade level. It governs the behavior of those units when confronted by various situations. It determines which formations to use, when to advance or halt, when to attack or defend, etc. The behavior of brigades, divisions, etc. are partly governed by the characteristics of the individual commanders and partly on a dice roll.

These are the types of decisions that, for the most part, your game needn't address as yours is more abstracted, using simple counters to represent these units. That allows you the freedom to concentrate on producing an AI that is much more strategic in nature and can do a far better job at recreating the overall feel of a battle in the various periods of 19th century warfare. At least I hope that's the case and it's not a simple one strategy fits all periods. That was the largest failure of NSD's move from Gettysburg to Waterloo.

The primary focus of NSD's games was to assume that the two armies were already in close contact and then regulate the fighting in some rational fashion. For the most part, they succeeded in this. They augmented this endeavor by creating a scripting system so various pieces of historic battles could be fought as they were historically. What NSD overlooked, was the fact that most players weren't interested in writing scripts to recreate historic battles. Instead, they wanted to quickly set up a generic encounter and fight that battle with the AI behaving as they would expect a human commander from that period to behave. As the Napoleonic period was the most complex of 19th century, people were greatly disappointed. It is that void that the KS mod has tried to fill.

While SOWWL does have substantial shortcomings, it is far from a simple table look-up game. It also has an advantage, in that much of the AI code is available for modding. If your game is to be a cut above this one, the AI will certainly have to be more oriented towards recreating battlefield behavior during that period. In addition it will have to build upon NSD's use of commander's personality traits.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Dr Ezra Sidran on Wed May 02, 2018 7:51 pm

It also has an advantage, in that much of the AI code is available for modding.

I did a quick look about the Internet and couldn't find the AI code that is available for modding. Could you please point me in the right direction?

Dr Ezra Sidran

Posts : 87
Join date : 2016-06-10

http://general-staff.com/

Back to top Go down

Re: Deciphering the AI system

Post  risorgimento59 on Wed May 02, 2018 8:06 pm

http://www.norbsoftdev.net/forum/waterloo-modifications/75449-waterloo-sdk-v2

You'll find the VC project inside the sowaiinf folder.
It would be so interesting to know any idea from you, sir.
Best regards.

risorgimento59

Posts : 20
Join date : 2015-06-19

Back to top Go down

Re: Deciphering the AI system

Post  Dr Ezra Sidran on Wed May 02, 2018 8:26 pm

You'll find the VC project is inside the sowaiinf folder.

I have Scourge of War Waterloo. This folder doesn't appear. There is, however, a sowaiinf.dll,

Dr Ezra Sidran

Posts : 87
Join date : 2016-06-10

http://general-staff.com/

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Wed May 02, 2018 11:20 pm

It is in the sdk. Here is the link: SOWWL SDK 1.02

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Didz on Thu May 03, 2018 12:59 pm

Dr Ezra Sidran wrote:I must confess that I bought SOW Waterloo and gave up on it pretty quickly. It didn't do much for me.
Hi Ezra, thank you for your interest.  As you have probably guessed I'm still struggling to understand this game despite owning it for over a year, and it's a bit of a love hate relationship which has seen me shelve it several times and vowing never to load the damned thing ever again.

My latest resumption of interest was triggered by discovering Mitra's video on 'How to use the AI?'

This video could have been a real breakthrough were it not for the appalling translation, and that it stopped just short of actually explaining how the AI works.  However, it was enough to get me interested in trying the game again and to try and fill in some of the missing information.  Hence this thread.

The impression given in the video is that the player can influence the behaviour of their AI commanders by giving them a stance.  It's a concept I'm more familiar with in fantasy roleplaying games and I'm not sure it makes a lot of sense in a battlefield context, but nevertheless that's what we are told. I guess the best analogy would be that one is imposing a level of aggressiveness or caution to ones AI leadership.

Mitra says there are seven stances which range from 'All Out Attack' at one extreme, to 'Hold to the Last' at the other.
e.g.
1. All Out Attack
2. Attack
3. Probe
4. Defend
5. Hold
6. Hold to the Last

The seventh stance is a bit of a mystery, as Mitra refers to it as both 'Neutral' and 'None', although in English these two terms are not synonymous.  My initial assumption was that the seventh stance was 'Neutral', e.g. it sat in the middle of the order between 'Probe' and 'Defend' and basically left the AI in a flexible tactical stance that allowed it to respond freely to any situation it was faced.

However, testing conducted by Hook on the Steam forum suggests that in fact it's 'None', and choosing it is actually a non-selection by the player, which leaves the AI free to allocate whichever of the other six stances it wishes.  This is fundamentally different and more dangerous, and as Hook stated in his test game the AI commander of Chalet's detached brigade with a stance set to 'None' arbitrarily chose to adopt a stance of 'All Out Attack' and destroyed his own brigade.  So, that's a key fact worth noting for a start.

My first desire was to try and determine exactly what influences each of the stances had over the AI.  Mitra mentions a few things in the video, but for some reason stops short of the obvious need for a tabular summary which lists how the stances vary from each other.  

The impression I have gathered so far is that each stance has two sets of variables associated with it.

  • One that only applies if the unit is moving.
  • The other that only applies when a unit is stationary.


These influences scale in opposite directions.  So, that the most extreme setting for a marching unit is 'All Out Attack', whilst the most extreme setting for a stationary unit is 'Hold till the Last', and consequently the least appropriate settings are the opposites e.g. The worst stance would be 'Hold to the Last' for a unit thats attacking.

However, beyond that things become shrouded in mystery, and there actually seems to be a reluctance to reveal how the system is designed to work.

My impression is that stances have a direct influence on:

  • The AI's Reaction Distance.
    (AI commanders become progressively more blind dependent upon the appropriateness of the stance they are in.  So, an AI Brigade moving in 'Hold to the Last Stance' is as blind as a bat and will stumble into any trouble thrown in its path.)
  • That the morale tests required to complete a maneuver (such as form square) become more challenging if the unit is in a poor stance.
    (e.g. A brigade defending in 'All Out Attack Stance' will be more likely to panic if attacked by enemy cavalry.)
  • That the formation schema's available to a Brigade are limited according to the stance they are in.
    [e.g. A brigade in 'All Out Attack Stance' is more likely to use assault columns, than a brigade in 'Hold to the Last'.  I've even read that for some reason a brigade in 'Hold to the Last' stance will not deploy skirmishers, which seems a bit odd, but may be linked to the schema options it has available.]


What's missing is any tabular summary of the reactions distances, morale impact, or schema options available with each stance, and so the player has no information upon which to decide which is the most appropriate to use in any given situation.

Add to that the additional mystery as to what exactly schema's are, how they work, and how they are selected and the whole system just becomes pointless complexity with no strategic value to the player. We are told for example that there are 60 x schema's available to AI commanders but that's all we are told. Again a simple table listing the 60 schema's, what they do and how they are selected would be an obvious improvement for the player.

I've actually switched back to Uncle Billies KS Mod now, simply based on faith that it is better at reproducing Napoleonic Tactic's.  
Plus it does at least have a player manual which i plan to study later today in the hope that its more informative than the standard game version.
http://forum.kriegsspiel.org.uk/t2032-ks-napoleon-mod-player-s-manual

But its still a hell of a lot of effort for a game that isn't really that rewarding as a simulation of Napoleonic warfare.
avatar
Didz

Posts : 145
Join date : 2017-07-03
Age : 63
Location : UK

Back to top Go down

Re: Deciphering the AI system

Post  Dr Ezra Sidran on Thu May 03, 2018 2:39 pm

Thanks for the opportunity to take a look at the AI underneath the hood for Scourge of War Waterloo.

The surprising thing that I found was that the code very much reminded me of my own code for UMS: The Universal Military Simulator that I wrote way back in 1986. At that time, my biggest constraint was the lack of RAM. UMS had to run on an MS DOS machine with 640K, the Atari ST, the Apple //GS, the Amiga and the earliest Macs. By the way, the program AND the operating system all had to fit into memory!

So, the original AI for UMS, and as far as I can tell after a pretty cursory look at the AI behind Scourge of War Waterloo, is what I would call 'reactive' AI. That is to say, it doesn't really plan ahead, it just reacts to events directly affecting the unit (should I run away? am I out of ammunition? etc.).

I also saw some code that looked like it was trying to deal with a classic early tactical AI problem first written about by Chris Crawford (Chris is a legendary wargame designer from the early '80s):


  • A unit 'wants' to attack
  • It advances
  • It sees that it's outnumbered
  • It retreats back to its start position
  • It wants to attack (loop forever)


I also saw some hard-coded values that the designer can change that set various 'threshold values' for behaviors (like the attack/retreat problem).

The code was written in C++ and seemed clean and professionally written.

Dr Ezra Sidran

Posts : 87
Join date : 2016-06-10

http://general-staff.com/

Back to top Go down

Re: Deciphering the AI system

Post  risorgimento59 on Thu May 03, 2018 3:26 pm

Dr Ezra Sidran wrote:
...as far as I can tell after a pretty cursory look at the AI behind Scourge of War Waterloo, is what I would call 'reactive' AI. That is to say, it doesn't really plan ahead, it just reacts to events directly affecting the unit (should I run away? am I out of ammunition? etc.).

I also saw some code that looked like it was trying to deal with a classic early tactical AI problem first written about by Chris Crawford (Chris is a legendary wargame designer from the early '80s):

   A unit 'wants' to attack
   It advances
   It sees that it's outnumbered
   It retreats back to its start position
   It wants to attack (loop forever)

Bingo!
This is exactly what I'm trying to bring to the general fanbase and modders attention since its release.
Nice to see I'm unqualified to speak but not totally idiot, yet.  jocolor
The code need to make a step forward sooner or later and adopt planning techniques, mates (Uncle&Mitra!).
Otherwise, despite attemps and claims, you will never handle satisfactorily many situations that need to be sorted out beforehand.
There's a lot of room for improvements to move from the actual reactional approach to a more reasoned/rational/cooperative/strategically recognizable (Didz!) one.
Not exhaustive and too expensive/continuous searches eh, but still it'd be time to start thinking in sequences-of-elementary-tasks-over-time terms.
And multiple layers of these, possibly.
Dropping if/then nightmare where possible.
It's not going to be easy of course.
For example we don't really have clean ways to make plans persistent across Think/Savegames, store some serious terrain, battle fronts & operational/contextual concepts (lines of operations, retreat, flanks, etc.) analysis either. But with creativity, you never know...
We could use couriers as "persistency vectors", carrying data encoded in particular protocols as free text messages and not removed from the OOB on delivery.
Same approach for influence maps.
Precomputed terrain analysis (we'd just need the scenario name).
We also have the command stacking system unused atm.
Just to name a few random ideas.

Virginians! With me! Who will come with me!?
Ehm, ok. I was joking. Very Happy

Best regards.
And a special thanks to Dr. Ezra Sidran for his contributions and inspiring presence, with the greatest admiration.
Almost wanting to go back to school. What a Face

risorgimento59

Posts : 20
Join date : 2015-06-19

Back to top Go down

Re: Deciphering the AI system

Post  Uncle Billy on Thu May 03, 2018 4:24 pm

Quite the conversation...

However, testing conducted by Hook on the Steam forum suggests that in fact it's 'None', and choosing it is actually a non-selection by the player, which leaves the AI free to allocate whichever of the other six stances it wishes.

Actually, it has a much greater effect. Battalions constantly ask their commander what they should do in many situations, (should I charge, should I form square, etc.). The commander's stance influences the answer to these questions. When the stance is set to none, the brigade commander tells the battalion to figure it out on its own, (the KS mod takes this a bit farther than the stock game). The battalion must decide what to do based on the generic rules it has for dealing with certain situations. sometimes times it leads to disastrous consequences, sometimes everything is fine. This is why the player should always set a stance for his subordinate.

What's missing is any tabular summary of the reactions distances, morale impact, or schema options available with each stance, and so the player has no information upon which to decide which is the most appropriate to use in any given situation.

It would do you no good. The AI uses many factors, not just the values in the stances table to make a decision, including dice throws. You would have no way to tell which factor(s) were used to make a certain decision based on what you saw on the battlefield. You want a simple 'if this is the stance, then is what will happen in the battle'. That doesn't happen in a real battle and it doesn't happen in this game. In general, the more aggressive the stance, the more risk the units will take to achieve their goal, even to the point of suicidal behavior.

A unit 'wants' to attack
It advances
It sees that it's outnumbered
It retreats back to its start position
It wants to attack (loop forever)
Except for the retreat part, that is a fair assessment. AI loops are run for all levels of command. It is mostly reactive, but does settle on a battle plan when the enemy comes into view. However, once the plan is set, it will not change it unless some very specific criteria are met, (mostly having to do with map objectives).

I disagree with your assessment of the code being clean, it's really quite messy. The use of the endless if/else statement, something students are taught to do in beginning coding classes for simple functions, is not appropriate in these complex rule situations. Many of the clauses in the AI code are completely unreachable. It suffers from the all to familiar splicing-on new criteria to the end of existing code, without taking the time and effort to integrate it properly by rewriting the function. It's an expediency we are all guilty of from time to time, but this code raises it almost to the level of religion.

_________________
I can make this march and I will make Georgia howl.
avatar
Uncle Billy

Posts : 3181
Join date : 2012-02-27
Location : western Colorado

Back to top Go down

Re: Deciphering the AI system

Post  Sponsored content


Sponsored content


Back to top Go down

Page 1 of 2 1, 2  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum