-
-
Günter Online
- Feldherr
-
- Beiträge: 674
- Registriert: Dienstag 1. April 2003, 04:00
Donnerstag 8. Dezember 2005, 18:29
von
Günter » Donnerstag 8. Dezember 2005, 18:29
Joe's Lösung müsste zwar klappen, aber es geht auch einfacher.
Es reicht, wenn du zu Beginn einfach die Immobile Units notierst und mit (disable self) abschließt.
Beispiel:
<pre>
(defrule
(true)
=>
(set-strategic-number sn-maximum-food-drop-distance 0)
(set-strategic-number sn-maximum-wood-drop-distance 0)
(set-strategic-number sn-maximum-gold-drop-distance 0)
(set-strategic-number sn-maximum-hunt-drop-distance 0)
(set-strategic-number sn-maximum-stone-drop-distance 0)
(set-strategic-number sn-food-gatherer-percentage 0)
(set-strategic-number sn-wood-gatherer-percentage 0)
(set-strategic-number sn-gold-gatherer-percentage 0)
(set-strategic-number sn-stone-gatherer-percentage 0)
(set-strategic-number sn-cap-civilian-explorers 0)
(set-strategic-number sn-percent-civilian-explorers 0)
(set-strategic-number sn-percent-civilian-builders 0)
(set-strategic-number sn-cap-civilian-explorers 0)
(disable-self))
(defrule
(true)
=>
(set-strategic-number sn-percent-enemy-sighted-response 100)
(set-strategic-number sn-enemy-sighted-response-distance 100)
(set-strategic-number sn-hits-before-alliance-change 25)
(set-strategic-number sn-percent-attack-boats 0)
(set-strategic-number sn-percent-attack-soldiers 0)
(set-strategic-number sn-task-ungrouped-soldiers 0)
(set-strategic-number sn-consecutive-idle-unit-limit 0)
(set-difficulty-parameter ability-to-maintain-distance 100)
(set-difficulty-parameter ability-to-dodge-missiles 100)
(disable-self))
(defrule
(true)
=>
(set-strategic-number sn-number-explore-groups 0)
(set-strategic-number sn-minimum-explore-group-size 0)
(set-strategic-number sn-maximum-explore-group-size 0)
(disable-self))
(defrule
(true)
=>
(set-strategic-number sn-number-boat-explore-groups 0)
(set-strategic-number sn-minimum-boat-explore-group-size 0)
(set-strategic-number sn-maximum-boat-explore-group-size 0)
(disable-self))
</pre>
Hier bewegt sich so gut wie nichts und:
die strategie bleibt veränderbar.
Beim Signal werden dann neue Strategien verteilt, die wiederum mit (disable self) abgeschlossen werden.
Beispiel:
<pre>
(defrule
(event-detected trigger 2)
=>
(set-goal 10 1)
(disable-self))
(defrule
(goal 10 1)
=>
(set-strategic-number sn-maximum-food-drop-distance 10)
(set-strategic-number sn-maximum-wood-drop-distance 10)
(set-strategic-number sn-maximum-gold-drop-distance 20)
(set-strategic-number sn-maximum-hunt-drop-distance 10)
(set-strategic-number sn-maximum-stone-drop-distance 0)
(set-strategic-number sn-food-gatherer-percentage 40)
(set-strategic-number sn-wood-gatherer-percentage 40)
(set-strategic-number sn-gold-gatherer-percentage 20)
(set-strategic-number sn-stone-gatherer-percentage 0)
(set-strategic-number sn-cap-civilian-explorers 0)
(set-strategic-number sn-percent-civilian-explorers 0)
(set-strategic-number sn-percent-civilian-builders 40)
(disable-self))
(defrule
(goal 10 1)
=>
(set-strategic-number sn-number-explore-groups 1)
(set-strategic-number sn-minimum-explore-group-size 1)
(set-strategic-number sn-maximum-explore-group-size 2)
(disable-self))
(defrule
(goal 10 1)
=>
(set-strategic-number sn-percent-attack-soldiers Prozent-Angriff)
(set-strategic-number sn-attack-intelligence 100)
(set-strategic-number sn-defense-distance 100)
(set-strategic-number sn-sentry-distance 100)
(set-strategic-number sn-target-evaluation-siege-weapon 100)
(set-strategic-number sn-target-evaluation-damage-capability 100)
(set-strategic-number sn-number-attack-groups 2)
(set-strategic-number sn-minimum-attack-group-size min-Angriffstrupp)
(set-strategic-number sn-maximum-attack-group-size max-Angriffstrupp)
(attack-now)
(enable-timer 1 Angriffs-Intervall)
(enable-timer 3 6)
(enable-timer 4 6)
(enable-timer 5 6)
(disable-self))
(defrule
(timer-triggered 1)
=>
(disable-timer 1)
(enable-timer 1 Angriffs-Intervall)
(attack-now))
(defrule
(timer-triggered 3)
(gold-amount less-than 1000)
=>
(disable-timer 3)
(enable-timer 3 6)
(cc-add-resource gold 1000))
(defrule
(timer-triggered 4)
(food-amount less-than 1000)
=>
(disable-timer 4)
(enable-timer 4 6)
(cc-add-resource food 1000))
(defrule
(timer-triggered 5)
(wood-amount less-than 1000)
=>
(disable-timer 5)
(enable-timer 5 6)
(cc-add-resource wood 1000))
(defrule
(event-detected trigger 13)
=>
(disable-timer 3)
(disable-timer 4)
(disable-timer 5))
(defrule
(goal 10 1)
(unit-type-count-total villager less-than Dorfbewohner)
(can-train villager)
=>
(train villager))
(defrule
(goal 10 1)
(unit-type-count trade-cart less-than 3)
(can-train trade-cart)
=>
(train trade-cart))
(defrule
(goal 10 1)
(unit-type-count trade-cog less-than 2)
(can-train trade-cog)
=>
(train trade-cog))
(defrule
(goal 10 1)
(unit-type-count-total scout-cavalry-line less-than 1)
(can-train scout-cavalry-line)
=>
(train scout-cavalry-line))
(defrule
(goal 10 1)
(unit-type-count-total spearman-line less-than Infanterie)
(can-train spearman-line)
=>
(train spearman-line))
(defrule
(goal 10 1)
(unit-type-count-total skirmisher-line less-than Schuetzen)
(can-train skirmisher-line)
=>
(train skirmisher-line))
(defrule
(goal 10 1)
(unit-type-count-total knight-line less-than Kavallerie)
(can-train knight-line)
=>
(train knight-line))
(defrule
(goal 10 1)
(unit-type-count my-unique-unit-line less-than Unique)
(can-train my-unique-unit-line)
=>
(train my-unique-unit-line))
(defrule
(goal 10 1)
(unit-type-count-total battering-ram-line less-than Belagerung)
(can-train battering-ram-line)
=>
(train battering-ram-line))
</pre>
Damit kann man beliebig viele Signale verarbeiten, ohne strategisches Durcheinander zu verursachen.
Ausserdem ist die Verwendung von goals sehr empfehlenswert, wie im Beispiel angegeben.
Damit kann man die KI nach Belieben abändern.
Hier noch die Konstanten für deine KI:
<pre>
#load-if-defined DIFFICULTY-EASY
(defconst Dorfbewohner 14)
(defconst Infanterie 6)
(defconst Schuetzen 4)
(defconst Kavallerie 2)
(defconst Unique 2)
(defconst min-Angriffstrupp 6)
(defconst max-Angriffstrupp 10)
(defconst Prozent-Angriff 70)
(defconst Belagerung 2)
(defconst Angriffs-Intervall 240)
#end-if
#load-if-defined DIFFICULTY-MODERATE
(defconst Dorfbewohner 16)
(defconst Infanterie 8)
(defconst Schuetzen 6)
(defconst Kavallerie 3)
(defconst Unique 3)
(defconst min-Angriffstrupp 8)
(defconst max-Angriffstrupp 12)
(defconst Prozent-Angriff 80)
(defconst Belagerung 3)
(defconst Angriffs-Intervall 180)
#end-if
#load-if-defined DIFFICULTY-HARD
(defconst Dorfbewohner 18)
(defconst Infanterie 5)
(defconst Schuetzen 5)
(defconst Kavallerie 10)
(defconst Unique 4)
(defconst min-Angriffstrupp 10)
(defconst max-Angriffstrupp 20)
(defconst Prozent-Angriff 90)
(defconst Belagerung 4)
(defconst Angriffs-Intervall 120)
#end-if
</pre>
Kopier das doch mal in einen Editor und teste es aus.
Die Zahlen bei den Konstanten kannst du nach Bedarf ändern.
Günter
ps: dieses Beispiel ist aus "Daniel the Brave", Dateiname "dtb5.per"