Force multiplayer AI to always recruit same units turn 1?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
Kharn
Posts: 82
Joined: December 12th, 2005, 7:50 pm
Location: Dallas, Tx

Force multiplayer AI to always recruit same units turn 1?

Post by Kharn » July 25th, 2014, 6:34 pm

Why is the code below not causing the AI in multiplayer to create 10 supply trucks on turn 1?

According to the WIKI (http://wiki.wesnoth.org/AI_Recruitment#Examples) My code should work.

EDIT: I have now even tried 2 separate [ai] tags with turns=1-2 on the first and turns=3-500 on the second. The turns=1-2 [ai] sets limits to recruiting for everything to be zero, yet still on turn 1 and 2 it recruits everything and follows the rules of the other [ai] tag. I feel like I am running out of ways to do this.


Bonus points: It seems no matter how high I set scout village targeting, scouts choose to fight over capping a village, which is far more beneficial than lightly wounding a unit. Is 60 just not enough?

Code: Select all

	    [multiplayer_side]
        id=Germany_HugeMap
        name=Germany AI:Hugemap
        type=Factory_Germany_AI
        leader=Factory_Germany_AI
		random_leader=Factory_Germany_AI
		image="portraits/germany.png"
		recruit=BGEGeneral, BF109E_AI, Stuka_AI, Fighter_Bomber_AI, Bomber_AI, SdKfz232, Panzer_IIF, Panzer_IIIM, Stug_3G, Panzer_IVG, Tiger, King_Tiger, Rifleman, SMG, LMG, MG42, Medic, Sniper, ATR, Supply_Truck, 37mm_ATG, Towed_75mm_ATG
		music=
        terrain_liked= ^F*
        [ai]
			recruitment_pattern=Scout, Scout, Scout, Scout, Scout, Scout, Scout, Scout, Scout, Scout, Scout, Scout, ATI, Close_Infantry, Medium_Infantry, Heavy_Infantry, Support_Infantry, AntiInfantry, Air_Dominance, Air_Dominance, Light_AntiTank, Heavy_AntiTank 
			leader_value=1
			scout_village_targeting=60
			village_value=4
			[aspect]
				id=recruitment_instructions
				[facet]
				  turns=1-2
				  [value] 
					[recruit]
					  type=Supply_Truck
					  number=10
					[/recruit]
				  [/value]
				[/facet]
			[/aspect]
			[aspect]
				id=recruitment
				#currently limits infantry upkeep to 66 per turn
				[facet]
					[value]
						name=ai_default::recruitment
						[limit]
							type=Rifleman
							max=4
						[/limit]
						[limit]
							type=SMG
							max=9
						[/limit]
						[limit]
							type=LMG
							max=6
						[/limit]
						[limit]
							type=MG42
							max=6
						[/limit]
						[limit]
							type=Medic
							max=4
						[/limit]
						[limit]
							type=Sniper
							max=10
						[/limit]
						[limit]
							type=ATR
							max=9
						[/limit]
						[limit]
							type=Supply_Truck
							max=10
						[/limit]
						[limit]
							type=BGEGeneral
							max=0
						[/limit]
						[limit]
							type=SdKfz232
							max=2
						[/limit]
						[limit]
							type=Panzer_IIF
							max=0
						[/limit]
						[limit]
							type=Panzer_IIIM
							max=1
						[/limit]
						[limit]
							type=Stug_3G
							max=9
						[/limit]
						[limit]
							type=Panzer_IVG
							max=7
						[/limit]
						[limit]
							type=Tiger
							max=3
						[/limit]
						[limit]
							type=King_Tiger
							max=4
						[/limit]
						[limit]
							type=BF109E_AI
							max=12
						[/limit]
						[limit]
							type=Stuka_AI
							max=1
						[/limit]
						[limit]
							type=Fighter_Bomber_AI
							max=1
						[/limit]
						[limit]
							type=Bomber_AI
							max=0
						[/limit]
						[limit]
							type=37MM_ATG
							max=0
						[/limit]
						[limit]
							type=50mm_ATG
							max=0
						[/limit]
						[limit]
							type=Towed_75mm_ATG
							max=2
						[/limit]
					[/value]
				[/facet]
			[/aspect]
		[/ai]
    [/multiplayer_side]
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.

User avatar
FaeLord
Posts: 343
Joined: March 2nd, 2012, 3:12 pm
Location: Seattle, WA

Re: Force multiplayer AI to always recruit same units turn 1

Post by FaeLord » July 28th, 2014, 8:41 pm

I don't know much about AI coding (I rarely use it) and nothing about multi-player (I only program single player campaigns), but if I needed to do this, I would just use turn 1 event and a GENERIC_UNIT or LOYAL_UNIT macro as appropriate. In fact, I do it quite often when I want a side to have particular units to start off with that the ai would not likely recruit otherwise.

FaeLord
Wesnoth stole my summer . . . again.

Kharn
Posts: 82
Joined: December 12th, 2005, 7:50 pm
Location: Dallas, Tx

Re: Force multiplayer AI to always recruit same units turn 1

Post by Kharn » July 29th, 2014, 7:41 am

Where would you put the [event] tag?

Update: Putting the following in the [ai] code does not work either.

Code: Select all

         [function]
         name=opening
         inputs="ai"
         formula="
         if(ai.turn = 1,
                     #turn 1
                     [ recruit('Supply_Truck'),
                       recruit('Supply_Truck'),
                       recruit('Supply_Truck'),
                       recruit('Supply_Truck'),
                       recruit('Supply_Truck'),
                       recruit('Supply_Truck'),
                       recruit('Supply_Truck'),
                       recruit('Supply_Truck')],
                []))))"
         [/function]
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.

User avatar
FaeLord
Posts: 343
Joined: March 2nd, 2012, 3:12 pm
Location: Seattle, WA

Re: Force multiplayer AI to always recruit same units turn 1

Post by FaeLord » July 30th, 2014, 2:54 am

You would have to put it in the [scenario] declaration. I am assuming that you've created scenario events before, but if not, best to review the WML reference on the [event] tag. If you want a particular side to always start with these units, you could alternately use the {GENERIC_UNIT} or {LOYAL_UNIT} macros inside the [side] tag for that side. But if you do that, that side will have those units immediately, and will get to move them immediately, giving them a definite advantage.

-=FL=-
Wesnoth stole my summer . . . again.

mattsc
Posts: 1124
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: Force multiplayer AI to always recruit same units turn 1

Post by mattsc » August 11th, 2014, 1:54 pm

Kharn wrote:Bonus points: It seems no matter how high I set scout village targeting, scouts choose to fight over capping a village, which is far more beneficial than lightly wounding a unit. Is 60 just not enough?
That's because of the way how the AI works. It consists of several candidate actions that are executed in order. The combat CA has a higher priority than the move-to-target CA (which moves scouts toward villages, among other things) or the villages CA (which grabs villages), so if a unit can attack and that attack is considered worthwhile by the AI, that unit will always attack instead of moving toward villages. If you don't want the scouts to participate in attacks you can exclude them using the attacks aspect.

Post Reply