OSP Kit Campaign Campaign AI Fixes and Tweaks

Users who are viewing this thread

I didn't think there'd be much discussion for my Campaign AI mod, but since there is some...

This thread is in support of the Campaign AI mod here:

http://mountandblade.nexusmods.com/mods/3614
http://mountandblade.nexusmods.com/mods/2475 (playable Native demo)

The Campaign AI mod restores campaign level activity and lord missions to those seen in early versions of Warband. The campaign map is much livelier.

Following is a summary of the changes:

General fixes
1. Put more party actions into play.
2. Don't restrict parties to castle on a 30% basis (for an army of ideal size 300, this can be quite a large party).
3. To balance #1, reduce amount of village raiding, in part by removing that as faction objective.
4. Resolve confusion between party size and party strength (size generally 1/20 of strength).
5. Resolve confusion between the scale of the two distance functions (one is 1/100 of other).
6. Avoid setting invalid AI objectives.
7. Prevent marshal from gathering troops at previous enemy objective.
8. Prevent marshal from getting stranded during operations.
9. Handle spai_screening_party better as a substate of spai_accompanying_army.
10. Apply lord personalities to process_hero_ai as well as party_set_ai_state.

Problem: Lords ignore each other
1. Tweak aggressiveness setting, updating.
2. Fix marshal’s screening party (now averages 150 troops, large enough to face enemies).
3. Have screening party for marshal at all times, not just after an offensive starts.
3. Have marshal’s followers get aggressive close to objective.
4a. Cause two nearby enemy marshals to attack rather than just pass by.
4b. Make parties aggressive when their commander joins battle.

Problem: Factions ignore trouble at home
1. Fix parties will reinforce their weak centers (if fall below 100 troops – not below 7).
2. Faction AI more dynamic (will get more defensive as it gets smaller, damaged).
3. Defend even if have more desirable attack if not going to attack anyway.
4. Generalize marshal emergency behavior.
5. Have faction defend even without a marshal.
6. Attack village raiders as well as town besiegers.
7. Generalize defensive behavior of attacking armies (instead of just patrolling the center being attacked).
8. Have patrolling armies stick close to the center they are patrolling.

Problem: Small marshals run away from objectives
1. Allow weak parties to recruit before other actions.
2. Put in low-priority recruit option for all parties (not just weak ones).
3. Weak marshals levy troops from over-defended centers (leaving garrisons of 100-700).
4. Add party size component to voting decisions (weight about 50% of renown).
5. Weak marshals lose renown (thereby leading to lower size expectations & better marshals elected).

 
Sweet, is it possible to make so factions fight with each other often, or in other term, launch crusades more often?
 
I think that's true, but remember that periodically the party leader changes his mission. It's either a standard trigger or fires whenever a diplomatic relation between factions changes. I'd have to look it up again. The list of options makes strict priorities. Since I moved recruitment for underpowered parties high in the list (to give underpowered marshals a chance to bulk up), you'll often see lords jet out of feasts to pick up taxes/recruits, and sometimes you'll even see them return to the feast.

I suppose it would be easy enough to add a condition that lords of particular psyche would NOT recruit during a feast.

dunde said:
Thanks for both answers. So, lower initiative point will make the party's leader has more chance to continue his objective without changing his mind in the middle, won't it?

I ask it, because after I implement Moto's tweak, my tournaments attract fewer heroes to join than before. They just come back to their centers in the way to tournament's town because a treat on their villages. I like it, it's more realistic, but I want some bad heroes will neglect the villagers life to look after the glory of tournament.
 
Actually, faction AI is quite a separate matter. I in fact DID overhaul it for Brytenwalda, but because Diplomacy's stuff was mixed in, I didn't make a mod of it. Some of the things I did was:

- restrict diplomacy to next-of-neighbor. Brytenwalda has 32 factions. It made no sense for Kent to suddenly decide to invade Munster six factions distant. M&B having only a handful of neighboring factions never had to develop such a mechanism.

- cultural antipathies. A big part of the Brytenwalda story is the clash of nationalities and/or religions, so I put in some biases there. Fanatically Christian Kent won't always attack fanactically pagan Mierce, but it's more likely to consider it.

One diplomatic thing IS in Campaign AI simply because it was easier to deal with it there. Campaign AI restricts objectives to the nearest walled center (no more attacking the empire next door from its far end!), but I added former or original centers to consideration. So in my Vaegir role in the Native application, for example, there was typically a back and forth with the Nords for Auburq, Jeribe, and the other border walled centers.

Belendor said:
Sweet, is it possible to make so factions fight with each other often, or in other term, launch crusades more often?
 
You are great, mate. The best one of the rare breed of AI coders over here.
If we don't give you much talk is because of the complexity and fine tuning of triggers that turns all this thing into black magic.

We all value and admire you work, don't even doubt about it. :smile:

Star Wars Conquest wouldn't be as half as fun as it is right now thanks to your scripts.
I haven't forgotten about when the combat consisted in massive brawls of guys wielding pipes, batons and stuff.


I've been starting to introduce myself in AI programming for creating the behaviours of some special units in the map lately.
For example, rare independent ore miners that wander around the asteroids from time to time, neutrals that avoid conflicts.

Random clone remnants in the less populated areas in the galaxy. And is fun once you get it, but extremely time consuming to tweak.
So much to take account of too, as you can't predict the player.
 
It is sad there is almost noone who took care of the "mission" AI. Bots are still noob-ass.

Is there anyway to disable the default AI, and apply your own methods? Either in Mission or on World?
 
Thanks again for sharing this code, motomataru.  I learn much from it. I like you create this threat so I won't spam the formation thread with questions about this code, later.

motomataru said:
I think that's true, but remember that periodically the party leader changes his mission. It's either a standard trigger or fires whenever a diplomatic relation between factions changes. I'd have to look it up again. The list of options makes strict priorities. Since I moved recruitment for underpowered parties high in the list (to give underpowered marshals a chance to bulk up), you'll often see lords jet out of feasts to pick up taxes/recruits, and sometimes you'll even see them return to the feast.

I suppose it would be easy enough to add a condition that lords of particular psyche would NOT recruit during a feast.
I haven't tested long enough to experience the lords leave the feast and come back again. On my mods, he can't leave the town if he still compete on the feast tournament. Leaving the town earlier, and he will be disqualified from the tournament if he miss his fight schedule.
I added 'stay at tournament' at script_npc_decision_checklist_party_ai before. I added under
(eq, ":do_only_collecting_rents", 0), along with native's list like hosting feast, etc before. As you deprecated this check, I move it on else_try before #following player order. It will keep the lord stay at the tournament town as long he still compete in. May be I will add some check according to lord personalities to give some condition that push him forgetting his tournament fight and do something else mor urgent.
Code:
       # MOTO end move functionality to party_set_ai_state to generalize
        (assign, ":action", spai_patrolling_around_center),                
        (assign, ":object", ":faction_object"),
        (try_begin),
          (eq, ":troop_no", "$g_talk_troop"),
          (str_store_string, s14, "str_as_the_marshall_i_am_leading_our_forces_in_search_of_the_enemy"),
          (str_store_string, s16, "str_i_intend_to_lead_our_forces_out_to_find_the_enemy"),
        (try_end),
      # (try_end), MOTO move functionality to party_set_ai_state to generalize
      
    (else_try),
      (faction_slot_eq, ":faction_no", slot_faction_marshall, ":troop_no"),
      (faction_slot_eq, ":faction_no", slot_faction_ai_state, sfai_attacking_enemy_army),
      (faction_get_slot, ":faction_object", ":faction_no", slot_faction_ai_object),
      (party_is_active, ":faction_object"),
      
      (assign, ":action", spai_engaging_army),
      (assign, ":object", ":faction_object"),
      (try_begin),
        (eq, ":troop_no", "$g_talk_troop"),
        (str_store_string, s14, "str_as_the_marshall_i_am_leading_our_forces_to_engage_the_enemy_in_battle"),
        (str_store_string, s16, "str_i_intend_to_lead_our_forces_out_to_engage_the_enemy"),
      (try_end),
  
  # Dunde's Tournament BEGIN
  #In a Town for a Tournament and still in competition
  (else_try),    
    (is_between, ":cur_center_no", towns_begin, towns_end),
    (eq, ":cur_center_no", "$g_tournament_town"),
    (troop_get_slot, ":current_tier", tournament_data, slot_tournament_tier_pointer),
    (troop_slot_ge, ":troop_no", slot_troop_tour_seed, ":current_tier"),
    (troop_slot_eq, ":troop_no", slot_troop_tour_withdrawn, 0),
    (assign, ":action", spai_holding_center),
    (assign, ":object", ":cur_center_no"),
    (try_begin),
      (eq, ":troop_no", "$g_talk_troop"),
      (str_store_string, s14, "str_i_am_in_the_tournament1"),
      (str_store_string, s16, "str_i_am_in_the_tournament2"),
    (try_end),    
  # Dunde's Tournament END

I realized about the recruiting priority upgrade, so I changed the center he will visit for recruiting to the tournament town if it's friendly and close enough.
Code:
   (try_begin),
      (ge, ":hiring_budget", ":reinforcement_cost"),
	  	  	  	  	  	  
      (assign, ":action", spai_holding_center),
      (assign, ":object", ":center_to_visit"),
	  
      (try_begin),
         (eq, ":troop_no", "$g_talk_troop"),
         (str_store_string, s14, "str_i_dont_have_enough_troops_and_i_need_to_get_some_more"),
         (str_store_string, s16, "str_i_am_running_low_on_troops"),
      (try_end),
    
    # Dunde's Tournament BEGIN
      # Well, recruiting and tournament at once. Who could ask for more?    
      (try_begin), # Change Direction to Tournament Town for registration
        (is_between, "$g_tournament_town", towns_begin, towns_end),
        (call_script, "script_get_relation_between_parties", ":party_no", "$g_tournament_town"),
        (ge, reg0, 0),
        (party_slot_eq, "$g_tournament_town", slot_town_has_tournament, 2),
        (party_get_position, pos0, "$g_tournament_town"),
        (party_get_position, pos1, ":party_no"),
        (get_distance_between_positions, ":dist", pos0, pos1),          
        (le, ":dist", 15000),
        (assign, ":object", "$g_tournament_town"),
        (try_begin),
          (eq, ":troop_no", "$g_talk_troop"),
          (str_store_string, s14, "str_i_want_to_join_a_tournament_for_gaining_troops1"),
          (str_store_string, s16, "str_i_want_to_join_a_tournament_for_gaining_troops2"),
        (try_end),        
      (try_end),

Belendor said:
It is sad there is almost noone who took care of the "mission" AI. Bots are still noob-ass.

Is there anyway to disable the default AI, and apply your own methods? Either in Mission or on World?
You should try Motomataru's FormAI.
 
Swyter: I thought you were releasing .904!  :grin: We had that problem in Brytenwalda, too. I think our last release was supposed to be a year ago, but we couldn't resist adding new features that then would need debugging. Well, it gave me the chance to put v4 of FormAI in it...

Player feedback is invaluable. I had no idea that what I had done here had affected tournaments, because I simply wasn't paying attention to them while running this code over and over again. It's many hours running the game through its paces, and it's sort of luck when you spot some odd situation. Happened to me with this, for example, when a Nord invasion by chance passed by a Vaegir invasion heading the other direction. No one attempted to attack outside the screening parties; hence my addition of the marshal-attack-nearby-marshal and followers-aid-embattled-marshal codes.

Belendor: you're probably right. The way I named this mod makes it seem much more far-reaching than it is. I really just wanted Native party AI to work better. Perhaps "Map Party AI" would be a better name.

Dunde: I really don't know how tournaments interface with party AI. What you did looks like one way to handle it, though you have to be sure you want the priority that high. Really what is needed is a mechanism to reorder this list depending on circumstances and NPC personalities. Not an easy project, but if I were doing it I'd first evaluate each option. You wouldn't have to track every one, simply keep track of the "high score" and which option produced it. THEN run the switch with the option chosen.

Your second solution: interesting, but why not? I doubt anyone would even notice a lord recruiting in a town that's not his base...

EDIT: But if he's outside his culture (e.g. a Nord lord at a Vaegir tournament), then he might get the wrong sort of troops. Check the recruit script to see whether it gets the recruit template from current center or somehow derives it from the lord. Dim recollection tells me it's the former. NM. It's based on the party's faction, so your solution will work.
 
motomataru said:
I had no idea that what I had done here had affected tournaments, because I simply wasn't paying attention to them while running this code over and over again.
May be it won't effect native tournaments as they 're done from start tier to the end tier in one trigger only or when the player enter it from town menu. My tournament 's running schedule based and it will need  4-5 hours game time. The lords participate in the tournament must stay longer. I solved my problem by giving higher priority to the tournament if it's close and consider the tournament as something the lords must do business in the center.
 
- restrict diplomacy to next-of-neighbor. Brytenwalda has 32 factions. It made no sense for Kent to suddenly decide to invade Munster six factions distant. M&B having only a handful of neighboring factions never had to develop such a mechanism.

It would be awesome if you included that in this kit... I play Europe 1200 and it really annoys me when Ireland declares war on some Italian states :l
 
Hello mates, and specially hello, motomataru. Hope you read this.
I've seen on a curious mod your IA and Formations code implemented... with some great modifications.

In this code, not all the factions used the formations. It was a roman vs barbarian mod, so that the Romans used formations and the barbarions don't.

Do you know how can I modify the code to obtain this? Just apply the formations to some factions?

Thanks a lot!
 
mike56 said:
Do you know how can I modify the code to obtain this? Just apply the formations to some factions?
If you want to exempt the barbarian faction from the AI, modify lines 1069-1071 from formAI_scripts_wb.py
Code:
			(this_or_next|eq, AI_for_kingdoms_only, 0),
			(this_or_next|eq, ":ai_faction", fac_deserters),	#deserters have military training
			(is_between, ":ai_faction", kingdoms_begin, kingdoms_end),
Then they will always execute a simple charge.

If instead you want them to use the AI, but only not the formations, then have script_cf_battlegroup_valid_formation return 0 when it is called for them.

Hope this helps!
--M
 
Hi everyone, I was googling "m&b better AI mod" and I came across this mod. I really dislike the native AI - both campaign and battle AI - , so I would love to use this with any mod I play, so I had a couple of questions about it:

1. This is basically the same AI mod that is used in Prophesy of Pendor and Brytenwalda correct? Or is this an even better version of the AI they use?

2. I am a noob and have no clue regarding intalling this mod. I can install modules but I don't actually know how to install individual scripts like this, and the instructions on the nexus page seem to be for mod developers and people who know what they are doing. Could someone please give me a noob-friendly step by step guide on how to install this mod? Say I want to use this with the Europe 1200 or Persino mods; how do I go about it? And which one of the files do I download? The "ready_to_play" one or the "script"?

3. As far as I can tell only PoP and Brytenwalda use this mod (as they specifically mention "improved campaign AI" in their feature list). Are there other mods that use this?

I know these are dumb questions but I would be very thankful if anyone could answer them. Thanks in advance  :smile:
 
Unless you have the source code files for the mod (most modders don't release them), you won't be able to implement this. Even if the source fikes were available, it'd take some degree of coding knowledge to avoid potential clashes with existing scripts.

Also someone correct me if I'm pulling this out of thin air, but I've always assumed this was already part of the diplomacy kit.
 
jacobhinds said:
Unless you have the source code files for the mod (most modders don't release them), you won't be able to implement this. Even if the source fikes were available, it'd take some degree of coding knowledge to avoid potential clashes with existing scripts.
Ah ok, that's unfortunate but fair enough. Thank you for clearing that up. I wish more mods implemented this; it's a pretty nice mod and in my experience of the mods that do have it (PoP I think), it works pretty nicely.

EDIT: By the way if anyone knows other mods that use this I would very keen to try them out. Cheers
 
I'm not aware of any mod that uses this, other than Brytenwalda, from which it came, even though it is basically a fix for Native.

The battle AI I think was modified for PoP. It was also merged with Diplomacy in PBOD, which is how it gets into many mods. These may include Perisno, Vympel's mods, Blood & Steel, and 1257. Oh, and it's in Caribbean. :smile:
 
motomataru said:
I'm not aware of any mod that uses this, other than Brytenwalda, from which it came, even though it is basically a fix for Native.

The battle AI I think was modified for PoP. It was also merged with Diplomacy in PBOD, which is how it gets into many mods. These may include Perisno, Vympel's mods, Blood & Steel, and 1257. Oh, and it's in Caribbean. :smile:

Oh PoP doesn't use the campaign AI form this mod? Ah ok then, I always assumed it did because it's AI seemed similar to Brytenwalda AI (i.e. both had less frustrating moments of marshals casually walking past desperately outnumbered friendly lords only to go loot a village with their 2000 strong army, or a faction holding a feast while their major city is under siege).

Regarding Brytenwalda I feel as if the battle AI had been further improved compared to it's implementations in other mods. The AI sends skirmishers forward to harass, then brings them back while charging infantry that maintain formation even DURING the fight, and also slowly back away to regroup with reinforcements if they start to run low in numbers all while continuing to maintain formation... it's just fantastic I absolutely love it :mrgreen:

Anyway glad to know that any mod with PBOD has at least the battle AI. Thanks for the awesome work and I hope more mods implement this in the future  :grin:

EDIT: Oh i just figured out what Caribbean is. So they actually used you mod in their game? Both campaign and battle AI?
 
Back
Top Bottom