I will update this as I come up with ideas.
(load "MyNewAIFolder/TrainingList")
Syntax: (load ""foldername"/"filename"")
(defrule
(conditions)
=>
(actions)
)
(defrule
(game-time >30) ;in seconds
=>
(chat-to-all "30 second mark!")
)
it is what ends a rule
(defrule
(conditions)
=>
(actions)
) ;<---Here?
(or
(condition 1)
(condition 2)
)
(defrule
(or ;<---- This is the "or" starter
(game-time >30) ;this is in seconds
(civilian-population >2)
) ;<--- This is the "or" ender.
=>
(chat-to-all "Game started!")
)
(defrule
(or(game-time >30)
(civilian-population >2))
=>
(chat-to-all "Game Started!"))
The "AI reader" will still read it the same way
(defrule(or(gametime >30)(civilian-population > 2))=> (chat-to-all "Game Started!"))
(and
(condition 1)
(condition 2)
)
(defrule
(or(game-time >60)
(and(game-time >30)
(civilian-population >2)))
=>
(chat-to-all "Game Started!"))
-to place this example in
(defrule
(or(game-time >30)
(or
(civilian-population >2)
(military-population >1)
)
)
=>
(chat-to-all "Game started!")
)
You can even compress that to:
(defrule
(or(condition 1)
(or <---- as "condition 2"
(condition 1)
(condition 2)
) <--- end the second "or"
) <--- end the first "or"
(defrule
(or(game-time >30)
(or(civilian-population >2)
(military-population >1)))
=>
(chat-to-all "Game started!")
)
;Say this would normally be your attack code.
;here it is using the "not" condition
(defrule
(military-population >10)
(players-military-population any-enemy <10)
=>
(attack-now)
)
;syntax is (not (condition 1))
(defrule
(not(town-under-attack)) ;force this condition to be only excluded
(military-population >10)
(players-military-population any-enemy <10)
=>
(attack-now)
)
(nor
(condition 1)
(condition 2)
)
(defrule
(nor(town-under-attack)
(game-time <600)) ;5min is 600 seconds
(military-population >10)
(players-military-population any-enemy <10)
=>
(attack-now)
)
(defconst "user definition" "value")
(defconst MaxFeudalVillagers 35)
;defconst stands for "define constant"
(defconst this number 35)
The compiler will just give you an error or a major bug. If needed you can just use the "_" symbol. Example:
(defconst this_number 35)
(set-goal "goal number" "value")
(goal "goal number" "value")
(defrule
(condition)
=>
(set-goal 1 1) ;sets goal "1" to value "1"
)
Or another prime example:
(defrule
(goal 1 1); any other value in goal "1" will be ignored in this rule
=>
(action)
)
(defconst Attack_now 1)
(defconst YES 1)
(defconst NO 2)
(defrule
(condition)
=>
(set-goal Attack_now YES); compiler reads this as set goal "1" to value "1"
)
Goal numbers can only range from 1-70 per AI, anything above "70" will not save the value you assign it. Goal values can range from -32,000 and 32,000... the standard short integer I believe.
(defrule
(goal Attack_now YES); compiler reads this as "if goal "1" is set to "1"" do...
=>
(attack-now)
)
(defrule
[b] (strategic-number sn-max-camp-distance < 10)[ /b]
=>
(set-strategic-number sn-max-camp-distance 10)
)
(defrule
(strategic-number sn-max-camp-distance <10)
=>
[b] (set-strategic-number sn-max-camp-distance 10)[ /b]
)
Example:
(defrule
(players-building-type-count any-enemy wonder >0)
=>
(set-strategic-number sn-special-attack-type1 wonder)
(set-strategic-number sn-special-attack-influence1 100)
)
(defrule
(enemy-captured-relics)
=>
(set-strategic-number sn-special-attack-type1 monastery)
(set-strategic-number sn-special-attack-influence1 100)
)
An example of a conditional load is:
#load-if-defined JAPANESE-CIV
(defrule
(game-time >0)
=>
(chat-to-all "Konnichiwa, I am japanese")
(disable-self);this rule cycles once and once only
#end-if
(defconst VillControltimer 10)
(defrule
(true)
=>
(enable-timer VillControlTimer 1)
(disable-self)
)
(defrule
(unit-type-count-total villager <100)
(or
(building-type-count town-center == 1)
(timer-triggered VillControltimer)
)
(can-train villager)
=>
(train villager)
(disable-timer VillControltimer)
(enable-timer VillControlTimer 15)
)
(defrule
(current-age >
(or
(building-type-count farm <
(idle-farm-count >
)
(not(town-under-attack))
(can-build farm)
=>
(build farm)
)
You can find me on steam: first_of_few
You can also find me at: www.aiscripters.com as 'Thegreatkazein' or 'Kazein'.
[This message has been edited by Leif Ericson (edited 08-19-2020 @ 02:59 PM).]