OSP Kit Combat Battlefield Tactics kit. Multiple formations per team+command revamp!

Users who are viewing this thread

One thought on that topic- a force-move that kept them in staggered lines (maybe 10-meter spacing, sawtooth) would probably work very well, for anything short of destrier simulation. 

Glob formations for cav just end up causing huge problems with horse-on-horse collisions, unless the cav's heavy enough to mow down whatever it hits.
 
xenoargh said:
One thought on that topic- a force-move that kept them in staggered lines (maybe 10-meter spacing, sawtooth) would probably work very well, for anything short of destrier simulation. 

Glob formations for cav just end up causing huge problems with horse-on-horse collisions, unless the cav's heavy enough to mow down whatever it hits.
Yeah, see othr's comments for historical lancers a couple pages back. He's thinking of an initial line charge, then devolving into Native. From a design viewpoint, I haven't worked out where the cavalry would set up that line or which battlegroup they would charge. But I guess that would be "destrier simulation..."

My initial intent was to replicate my player ability to send the cavalry wedge through vulnerable enemy battlegroups, but it's very complicated to automate.

I'd like to keep the formation for maneuvering -- it's historic and in fact a good way to move cavalry.
 
Here is a picture o charging lancers, 16th century unfortunately.  However this particular tactic remained largely unchanged since 200AD or so.  The charge starts in a loose formation, they pick up speed at 60 paces, tighten it into a 4 rank formation, crash into the enemy, switch to secondary weapons. I tried to get this to work Motomataru but I think I failed :sad:



The 4 rank formation would just hamper things in M&B because of horses rearing and riders bumping into each other so a single line would probably be the best.
 
S'OK, I hope to get to it within the month.

60 paces -- considerably more than the 20m or so I was giving for the charge.

I liked the charge through because I've noticed in M&B the cavalry seem vulnerable after the charge unless in heavy armor. Problem is (like in the picture here), there's usually no place to go.

Another thing I notice is that the lancers have chosen ranged troops/other cavalry to attack. I'll probably keep target acquisition for the charge -- that at least is a good routine.

So the way this is shaping up... Cavalry would advance with the rest of the army. At my (just added) long range decision point, they'd locate the nearest threat and target. If the threat is blocking the target, they try a flanking long range position. Once they have a line of attack, I release from wedge formation, and they form a line. Once the line is formed, I give them a new hold position just beyond the target position. Once they reach that position, I give them a charge order.

Problems I still have: getting clear of friendly archers, detecting when cavalry is in a line ready to charge, and the problem of what to do if there is no good target.
 
I think the missing link to the current formations kit here (from above discussions as well as from in game experience) could be that formations need a more variable ai to make it work.  Just being in formation could be just "eye-candy", (quoting motomataru form some other thread).  But plugin some basic ai, the eye-candy can turn poisonous.

I don't know exactly how the cavalry AI is being done, but just in case it is going to be hard coded, I would like to suggest a more general state-based framework. (iow finite-state automaton)

A typical state-machine ai  consists of small states which fixed behavior, some standard transitions to new states from each states, and a "tactics cycle" which is executed regularly to decide whether there should be a jumping change in tactics (as opposed to standard transitions).


Taking cavalry for example since it seems to be the current hot issue.

I define the following states, where the behavior of all units in formation is dependent on state.

"rally" state :
  Action: member agents (re)group together in some general location and reform formations
  Transit to "position" state once a certain threshold number of agents has been gathered or a certain amount of time has passed (no need to wait for all agents)

"tactical plan" state:
  Action: choose a point to attack, a point to attack from, and an attack type.

"position" state :
  Action: move to a chosen  attack point
  Transit to "pre-charge" state once certain number of member agents reached the attack point

"pre-charge" state:
  Action: form up into charge formation (line? but we can potentially have more options here).
  Transit to "charge-engage" or "charge-breakoff" or other charge type specific states. state once a number of agents is formed up (each agent can increase count once reaching the pt) or timeout has elapsed (no need to wait for all)

"charge-engage" state:
  Action: Charge to the attack target and break off into individual melee
    This is meant for mopping up weaker enemies or when locking range enemies into melee.
  Transit to rally if another charge is required.

"charge-breakoff" state:
  Action: Charge to some point beyond attack target and after that move to a rally point (chosen during "tactics cycle").  This is to prevent cavalry from getting locked into melee with potentially larger number of enemies.  To charge en masse to a small part of the enemies' groupings, deal damage in a small area, then break off before the  larger parts of the enemies' agents  can move in/surround the cavalry.
  Transit to "rally" after some agents reaches the rally point.

"rout-enemy" state:
  Action: disband formation.  Let all agents chase enemies on their own.  Used for eliminating weaker/routing enemies.


"tactics cycle": All agent groups run this regularly to evaluate and change tactics when needed.  E.g. when detected that cavalry doing "charge-engage" is in risk of being surrounded, may pick a rally point and transit to rally state and then start the charge cycle again. Or when there are only a few enemies left and most are fleeing, change to "rout-enemy" stage.

The above may not be doing more than what is being done atm, but just try to "breakdown" the whole tactics-execution loop.  And this can be used for all types of formations (not just cavlary), with only the states being different.  And potentially can have more advanced ai (which can be used by computer controlled side as well) which can actually CHANGE formations to suit the current situation.

I actually got this idea coz I am doing a map-level ai state-machine framework.  IT can allow quite interesting emergent behavior (of whole battle) by creating ai "agents" (not the scene agents) which are autonomous and yet can exhibit elaborate behavior through states. (An ai agent here = ai controlling 1 formation/group)

Another nice thing is that due to the standard way states transits and stuff, the same organization/structure can be used for all types of AI, and potentially made into a user-level framework (i.e. modder defines what are the states and how member agents should behave in each state, and what conditions does one state changes to another state, and the stuff like plugged into the correct spot in scripts/mission templates automatically by framework).

May not be making myself clear as my head is swimming atm... lol... But I think the next step to BTK, is group-level battle ai, and formations will be more than just a fixed eye-candy.  Anybody else up to changing the way battles will play out in MnB in the future??  :mrgreen:
 
Good collective AI is what this game sorely needs, the problem is each agent has its own individual AI and that's inaccessible to the modder.  Motomataru has a pretty tough task here, herding cats seems easy in comparison.

Motomataru's work is already a great improvement over the native AI, I'd like to see the AI use formations when they benefit it, formations for the sake of formations can really hamper the already weak AI.

I didn't bother to learn what all the pos0, pos1 stuff does, not like there is any documentation for it anyway, I will get to it and try to help out though.  This will take a lot of guessing and experimentation :sad:
 
That's why I suggest FSA.  hard scripting complex AI is well... complex.  But breaking it down into states is a lot easier.  The group ai machine then drives the agent ai using the in-built ai stuff (like move to a position etc)  That's how I'm structuring my map level ai framework: parties with FSA at high level called "missions", then "missions" will assign "tasks", and some tasks then drives the low level ai_bhvr.  This organization allows the low level tasks to be reused by different missions (as compared to hard-scripting each mission) and most importantly, allows missions to be changed very easily (by adding/removing states + changing transition conditions).  Think I can't really offer a better picture to those not familiar with FSA until I have a cleaned up example.  My map level example is working, but not fully structured into a end-modder usable system yet.

Maybe an analogy using the herding cats is : don't try to herd all the cats at once, but rather, put a radio-controlled collar on each cat which is taught how to herd the cat itself.  Then all we have to do is broadcast the right messages to the collars and we can have a cat carnival :smile:

EDIT: one more advantage: breaking down into states and tasks can enable cooperation between modders.  Tasks created by a modder can be used by states created by other modders. Potentially, we can have some people who specializes in adding new tasks (to allow agent group to do new things) and people who tweak the high level ai (to access the battle and decide when and where to do the tasks)
 
Is it possible to designate targets for agents, like a command for one agent to attack a specific other?
I think that would be a big part of basic ai, and improving it.

For example archers targeting enemies with less armour, and cavalry charging infantry rather than other cavalry etc.

Or is it only possible to move agents to a position, as I suspect?
 
Target acquisition is done by the game engine, ie. not moddable.

It is quite obvious how they select targets though:

1. player
2. if player not near or player on the same team nearest enemy, this is where it gets bad, at times the AI will ignore any 'near' targets and go for the player anyway until something smacks it, or the AI will chase routing enemies with no hope of catching them.
3. hate, whatever hit the agent the hardest gets attacked unless it gets out of range, this is also bad, AI footmen chasing cavalry, if that's the case it's the next target on the hate list or back to step 1
 
Yes exactly, theres so many important 'tasks' that modders will not be able to make, if the only ai that can be controlled is positioning. I really hope taleworlds adds at least a little more customisable ai for modders to utilise...
 
@sphere:
Native AI attempts to use states (Hold, Advance); main problem there was they chose states based on team composition when team size is the preeminent variable. My code goes by battle phase (Setup, Fight) and then by tactical choice made first by team size, then by tactical group, and lastly by a number of other variables sometimes including composition. As I refine this, more states come out: the code I'll release today (with any luck) has a third battle phase, Jockey, which is entered when the player choses to squirrel around.

I can provide a map of current AI logic (similar to what I did for othr for cavalry charge) if you want to design something more complete. I admit that the logic is more organic than clearcut...  :roll:
 
@motomataru
You're talking about the overall battle-level strategy right?  You just reminded me that we prob need a higher level ai to control the low level tactics.

So how about a skeleton like this:

high-level-strategy ai:


Analyze army size/composition/strengths/weaknesses and divide army into battle-groups (for ai, not necessary by division?).  And then it sets parameters group level tactics.  It may also change tactics settings during battle according to periodic analysis.  But at the most basic case, this is just called once at the start of battle which divides up an army into battle groups and set their tactics.

e.g. say it finds that it has higher score in range offensive than enemies, it may choose a defensive strategy (set formations to protect archers and stand group, or slowly advance towards enemy until archers can fire). Or if it finds it has overwhelming strength, a straight offensive may be used.

iow, strategic ai don't care about stuff like formation position/orientation etc.  It just picks general tactics which may then be translated into formations + tactic parmeters (e.g. offensive/defensive, aggresive/cautious, infantry/cavalry-centric or range-centric etc) and high level missions.  E.g. infantry group do frontal assualt range support infantry group, cavalry group1 harass enemy cavalry + try to flank enemy range.  But strategic ai don't care how it is done exactly.  commander just say, the formation officers (group-level tactics) will have to figure out how to achieve this.

This is the level that will prob be heavily personalized for individual mods that uses BTK, though BTK can provide a default one for Native.  After we build up the low level stuff, we can really leave this part for people to tweak out their best tactics.  Would be interesting if we can even hold strategic level ai competitions (i.e. all low level tactics/tasks identical, but high level strategic functions can use those created by different people, one for each side in a battle.  Then watch to see how two ai using those strategy will perform against each other)

group-level tactics ai:
These do not do overall analysis, but just act like robots (the FSA).  They need parameters from high-level-strategy and just follow them, doing some analysis at tactical level but and don't do strategic level stuff.  Also, each robot just manages a group and don't command other group (unless made to cooperate specially, e.g. shield infantry protects archer formations).  According to the states and stuff, each group will usually be executing a task.


group-task-level: (not ai. this is the "command signal transmitter" to send orders to the radio-controlled collars for individual agents)
Sends group level orders to individual agents (customized for each agent where applicable)
e.g.
- Group move to position (offensive, attack targets of opportunity)
- Group rout to position (non-offensive + disengage from combat)
- Guard a position (with an adjustable radius.  Within radius, will attack enemies as per normal (default charge?), but if too far from center, it will draw the agents back into range.
- Group set formation (where there should a special loose grouping where the group members just stay close together without a fixed formation)



agent-task-level: (the radio-controlled collars!)

on receipt of orders by "radio-collar"
- move agent to position
- make agent follow another friendly agent e.g. (leader)
- make agent engage enemy agents (just move close to engagement range, where actual range depends on active weapon)
- make agent guard a position (with adjustable radius)
- set agent stance (aggressive/guard/passive) (possible?)
- select/switch agent weapon
- default behavior (where it should behave just like the case without BTK)

I'll have to get my hands more dirty with the mission templates (esp the special triggers) before more can be done, but it would be a good start if we can start collecting script fragments/references that can do stuff like above list (incomplete and need to be revised)  Then I'll see if I can come up with modular way for modders to define tasks/states at the various levels above (strategic level can be left to individual mods that uses BTK though) and how to parse and compile these definitions directly into game data which works.

But from prelim study, it seems that we cannot escape from arrays and globally defined ones may not be enough, especially when we need a variable number of "object"s to hold ai states + task states at group level which should not be tied to agents, since when agents die, we will lose its data.  Agent level tasks can be embedded into agent slots though.

Personal question: can party objects be created during battle missions? (I'm using parties as dynamic arrays atm)

EDIT: btw, I am not really looking at creating tactics that work, but rather thinking of some sort of organization where different people can come together to design tactics and tasks which can then be used together, hopefully making it easier to tweak existing tactics or to design new ones.
 
So, I've got most of this already, but I know it's not terribly accessible. It'd be nice to have an easy-to-use framework that others could change, 'cause right now the AI plays just like I would...  :shock:

sphere said:
Analyze army size/composition/strengths/weaknesses and divide army into battle-groups (for ai, not necessary by division?). 

AI troop division IS class, as far as I can tell, but by using class, troops automatically migrate. If you've ever been annoyed by how your unhorsed cavalry follows their mounted division-mates around, you know why I "switch horses" for the AI.  :mrgreen:

sphere said:
Would be interesting if we can even hold strategic level ai competitions (i.e. all low level tactics/tasks identical, but high level strategic functions can use those created by different people, one for each side in a battle.  Then watch to see how two ai using those strategy will perform against each other)

On a side note, I've finally matched Native unformed charge using formations in Custom Battle, but it takes a very active commandership. I still test infantry in formation as way worse than infantry out of formation--perhaps for a reason as simple as they don't split up and chase down Native charge cavalry that conveniently park 20m away.

 
long-comments ahead warning  :mrgreen:

motomataru said:
On a side note, I've finally matched Native unformed charge using formations in Custom Battle, but it takes a very active commandership. I still test infantry in formation as way worse than infantry out of formation--perhaps for a reason as simple as they don't split up and chase down Native charge cavalry that conveniently park 20m away.

regarding infantry, just a suggestion: vary spacing.  I found that using default spacing, it isn't good against no formation coz the opposing side can gang up on a few of your guys while those agents further away in formation just stand there watching.  Since there isn't a "guard radius" for the agents in a formation slot, the next best thing could be to tighten up formation, so that on average, when contacting enemies, we will have more agents per contact edge length.  Bonus if there are long range weapons that doesn't need much space (like spears) where 2nd row can potentially attach as well?

Also, many times, I wished there is possibility of (automatic or commanded) rank switching when rank in front gets too injured: i.e. 2nd rank replaces 1st rank, 1st rank goes to back etc.  This will greatly increase survivability.  But I think this could be a minor feature which isn't critical.

I still believe that formations can provide real advantageous that doesn't need "cheating" (in many other games, formations gives artificial bonuses and penalties).  E.g. if a phalanx formation can probably wipe out a like number of loose infantry agents, but it should be a function of battle mechanics (equipment like shield + long reach of weapons that don't need a lot of space which is suitable for tight formation).

And one more suggestion I have is: don't be restricted by historical formations.  Although those are good references born out of real experience, the game-mechanics may not model reality well enough for those to work.  Rather, think of how we can try to maximize our own troop's advantage if we had the power to micromanage everything.  Except that the micromanagement is simplified into standing orders for formations.

Another thing I realised is that keeping to same formation througout the battle and expecting it to perform well all the time is not realistic.  for example, when an infantry rank is locked into melee, sometimes, it is better that the whole formation temporarily breaks to allow your troops to surround the enemy (esp when they approach in a width narrower than your ranks).  Your troops in formation may already have the natural advantage of being relatively close together while waiting for enemy contact.  Bonus if your infantry have throwing weapons that could be expended before locking into melee ad stuff like that.

All in all, I don't know enough yet, but just discovering possibilities as I go along.

Another thing I find limiting is the game's use of dividing army by troop type.  e.g. I can't split same troop type into 2 individually commandable "divisions".  That sort of prompted me to do a little investigation into whether we can create temporary divisions by activating some pre-declared "blank"  troops, then copy over all the troops data from existing troops, use them for battle, then latter join everything back.

e.g. say I have 100 swadian infantry.
I wanted to split into 2 "divisions", so I request for a blank troop (one of a list of dummy troops declared in module_troops.py) and then copy over all the skills/attributes and equipment etc, then remove 50 of original infantry and add 50 of the "copy".

e.g. assume I have 100 of 1 troop in a party troop slots
+ 100 swadian infantry

After the "dividing"
becomes
+ 50 swadian infantry
+ 50 swadian infantry (This is a copy, and have a different troop id, but display name stats etc is copied from original swadian infantry)

And since the two slots are essentially different troops underneath, they can be assigned to different divisions.
This can open up some interesting possibilities in battles even without formations.

This can be retained constantly (but takes up blank troops), or can be merged back into 1 slot after battle and only redefined before each battle (more complicated, and probably need some way to remember last division so that there is a default option that quickly setup divisions like last time)
 
sphere said:
Another thing I find limiting is the game's use of dividing army by troop type.  e.g. I can't split same troop type into 2 individually commandable "divisions".

Might you be able to accomplish this with an agent slot ? Loop through all the troops of a given type, count how many there are and then divide that number by however many divisions you want. Loop through them again to set_agent_slot of the first X to slot_agent_division = 1, the next X to 2, so on and subsequently have their actions dictated by the value of their slot_agent_division?
 
I agree that historical accuracy has to take a back seat when doing the AI.  The main focus should be on presenting the player with a tactical challenge, and that means working within the constraints of the game engine.

In my mod units are divided by the weapon type they use.  The infantry man (called the swordsman in the mod) with a decent shield and good shield skill was to offer protection for archers and other vulnerable troops, the spearman was to offer protection vs cavalry attacks and troops equipped with 2h weapons were to be the shock troops and can openers.

Medieval rock, paper, scissors so to say.
 
Hi thank you for epic mod Motomataru.
Im trying merging your mod and own mod.
But I have a question.
Can I set ModAI does not apply to bandits?

Sorry for my bad English :sad:
 
cimo said:
Can I set ModAI does not apply to bandits?
You know, this has crossed my mind. I think I even saw a description for Nords that said something about them not using formations. Though I do think those Sea Raider wedges are awesome and historically appropriate.

At any rate, I'd need to split out the faction identification section of script_get_default_formation and then call the new script as a condition to the main AI trigger (plus a global tweak switch for modders like you). Then, AI off, they'd just charge like in old Native.

This is pretty simple. As I have a scheduled release this weekend anyway, I can slip it in.

Now as far as TROOP level AI switches, this would involve more thought & effort & a troop slot...
 
motomataru said:
Now as far as TROOP level AI switches, this would involve more thought & effort & a troop slot...

Maybe it wouldn't need a slot...might a caveat in cf_valid_formation_member that, by troop ID, makes it so bandits (and perhaps green recruits) are not valid formation members work?
 
Back
Top Bottom