Subotai 0.9

Upload your latest creations here.
Please note that by posting comments to posts in this forum you forfeit your personal copyright on whatever you post. AI Scripters reserves the right to re-use objective comments in script reviews without requiring the posting author's permission. Credit, where appropriate will be given in such cases.
User avatar
THE RULER
Guru
Posts: 655
Joined: Sat Feb 20, 2010 10:55 am
Location: FRG
Contact:

Re: Subotai 0.4

Post by THE RULER »

if your evaluation attack fails vs a better script then gg already

after about 18 minutes you cannot change a started strategy any more, if the enemy has the perfect counter (in most cases)
so your decision has to be taken before and then must be executed in the hope that the enemy hasn't the perfect counter.
sometimes you are lucky and get the enemy information before so that you can select the best choice.
some civs have very convincing strats for Ai combatting -they are well known, often rescripted and therefore boring in their repetition.
It's poison and it's blood and big fire, big burn - into the ashes and no return

User avatar
kram1138
Guru
Posts: 815
Joined: Sun Jun 26, 2011 11:54 am
Location: Winnipeg, Canada

Re: Subotai 0.4

Post by kram1138 »

This is exactly what i am doing with Fire. It will change the strategy only if its previous one is not too far advanced. And then ever after that it will only have minimal countering, and only train counter units of the same type as the main unit, or if absolutely necessary. For example, if doing an eagle rush it will train pikes to counter knights but not skirmishers to counter archers, since eagles are still alright vs them. On the other hand if doing an xbow rush, if the opponent krushes, you have no chance if you stick to xbows + very few infantry as meatsheild, so it will train many pikes
PostCount.Add(1);

User avatar
Mandulis
Forumer
Posts: 28
Joined: Sat Mar 31, 2012 9:41 am
Location: at home

Re: Subotai 0.4

Post by Mandulis »

Just updated my attack rules to get them streamlined, too. Maybe I find a working system. Since everybody around here was really helpful I'll share the code. If someone can get some new ideas out of it I am happy. :dance

So here's the code from the main script:

Code: Select all

(defrule
	(goal g-attack 1)
	(timer-triggered attack-timer)
=>
	(set-strategic-number sn-percent-attack-soldiers 100)
	(attack-now)
	(chat-to-player my-player-number "40 Attacking")
	(enable-timer attack-timer 100)
)
My main script is not attacking unless being told so by a strategy. I have not encountered a situation yet where I did not want to attack with every unit possible. The timer seems fine, too.

Here is the sceleton for the strategy script:

Code: Select all

;-------------------------------basic attack (attack if superior)------------------------------------

;attack before castle age if enough soldiers are present
(defrule
	(strategic-number sn-military-evaluation > 0); military superiority => attack
	(strategic-number sn-current-age <= fc-transit)
	(soldier-count >= 20)
=>
	(set-goal g-attack 1)
)
;attack only in castle age if we have rams
(defrule
	(strategic-number sn-military-evaluation > 0); military superiority => attack
	(strategic-number sn-current-age == castle-phase)
	(unit-type-count battering-ram-line > 2)
=>
	(set-goal g-attack 1)
)
;break equality
(defrule
	(strategic-number sn-military-evaluation >= 0)
	(military-population >= 70)
=>
	(set-goal g-attack 1)
)
;---------------------------basic defense (defend if not superior)--------------------------------
(defrule
	(strategic-number sn-military-evaluation < 0); military superiority lost
=>
	(set-goal g-attack 0)
)
(defrule
	(goal g-attack 1)
	(players-building-count every-enemy == 0); set attack goal to 0 when enemy not yet found.
=>
	(set-goal g-attack 0)
)
;---------------------special attack rules (attack even if not superior)---------------------------
;IMPORTANT! overwrites defense rules

;distract enemy economy early when we can still recover from a loss
(defrule
	(goal g-attack 0)
	(or
		(unit-type-count scout-cavalry-line > 2)
		(and
			(unit-type-count archer-line > 1)
			(unit-type-count spearman-line > 3)
		)
	)
=>
	(set-goal g-attack 1)
	(chat-to-player my-player-number "Distracting Rush")
	(disable-self)
)
;----------------------special defense rules (defend even if superior)--------------------------
;IMPORTANT! overwrites attack rules

The attack is done in four steps:
1. General attack rules say that we attack when we are superior. These rules also include age-specific stuff. In my example I only charge in the castle age if I have rams against castles.
2. Defend rules say when defend, usually when not superior. These rules should not contradict with the attack rules. They just specify the attack or defense.
3. The special attack rules allow you to attack outside of the general attack rules. Sometimes you have to charge even if not being superior or not having rams in the castle age or whatever. This stuff will overwrite the defense rules so you have to be careful and think ahead.
4. Finally the special defend rules. I put these last to avoid desaster. They can override all other rules. General attacks can be called off and even special attacks. If haven't found a case for this yet but I am sure there are some.

I tested this system in a couple of games and seems to work quite well. It avoids some serious loss of units through stupid charges with archers against castles when no rams are present.

Archon
Waheguru
Posts: 1905
Joined: Sat Nov 08, 2003 9:22 am

Re: Subotai 0.4

Post by Archon »

I'd set the attack goal to zero at the start of every rule pass. This requires you to change the rule order, so it would looks like: clear attack status => conditions => attack command

As it is now, for example your distracting rush would cause it to continuously launch attacks until it's in military disadvantage, assuming sn-military-evaluation 0 means equal.

There is a chance it may never use the distracting rush, as it may launch that one time rule before it actually sees an enemy building, result in setting attack goal to zero before any attack is launched.

User avatar
Mandulis
Forumer
Posts: 28
Joined: Sat Mar 31, 2012 9:41 am
Location: at home

Re: Subotai 0.4

Post by Mandulis »

My mistake, forgot to post that. Of course the main script always sets the g-attack goal to 0 every rules pass.

User avatar
Mandulis
Forumer
Posts: 28
Joined: Sat Mar 31, 2012 9:41 am
Location: at home

Re: Subotai 0.5

Post by Mandulis »

Ok, the first stable version is up. Still a lot of stuff needs to be done but at least it should be able to play all ages and get some fighting done. I'll focus on some technical stuff next and do more strategies later afterwards.

User avatar
Mandulis
Forumer
Posts: 28
Joined: Sat Mar 31, 2012 9:41 am
Location: at home

Re: Subotai 0.5

Post by Mandulis »

I finished the first version of my scalable threat system and am quite pleased for now. The script detects several threats like archers, infantry or anti-cavalry and trains the apropriate amount of counter units. The larger a threat grows (the more units of a type are trained by the enemy) the more resources and buildings are devoted to the threat. A few pikes do not bother me, 10 require archers as counters, even more are fought with additional swordsmen and large numbers are also countered with scorpions. With dealing with threats this way I can create a dynamic resource usage. No enemy can produce huge threats of every type. You either have few large ones are many small ones. Now I can adapt to that and still pursue my main unit strategy.

Where I am struggling is unit spreading. On black forrest maps my units sometimes blocked each other. So I found this sn-task-ungrouped-soldiers. I deployed timers so my units are spread for 1 second every 180 seconds. The clogging is solved but now my units spread out across the map and do not help each other well. Also gathering troops for an attack takes more time. All in all it is a huge disadvantage as it is now. What I would like to have would be a spreading of troops, but rather close to my town centers. Is that possible (maybe with up) and how could I do this?

User avatar
Pasadema
Yogi
Posts: 291
Joined: Sun Feb 18, 2007 1:54 am

Re: Subotai 0.5

Post by Pasadema »

You can use the retreat commands to either retreat to town-center or another building in your town every so often.

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Subotai 0.5

Post by Campeador »

The Horde uses sn-task-ungrouped-soldiers, setting it to 1 for a few seconds and to zero for a few minutes. And it works well. I imagine that your soldiers are always spreaded because you are not using well the times (although I haven't studied your code this time). I suggest you to study it in the Horde, searching the word sn-task-ungrouped-soldiers with the menu "Edition=>Find...".

User avatar
Mandulis
Forumer
Posts: 28
Joined: Sat Mar 31, 2012 9:41 am
Location: at home

Re: Subotai 0.5

Post by Mandulis »

Ok, I looked that up. It seems the horde is just doing better because it attacks very often and is never really just gathering units. My AI needs to improve on that. Aside from that, wich method would you recommend, sn-task-ungrouped-soldier or retreat?

Post Reply