-
Notifications
You must be signed in to change notification settings - Fork 0
06 Adjust resource gatherer percentage.
Satoshi Teshiba edited this page Jan 17, 2021
·
3 revisions
Adjust the resource gatherer percentages, then can research the feudal age faster while training villagers. Write the following C # code.
using System;
using System.Collections.ObjectModel;
using LibAoe2AISharp.Framework;
namespace Aoe2AISharpSample
{
class Program
{
static void Main(string[] args)
{
var gameStarting = new CommandCollection("Init") {
new DarkAgeGathererPercentages(),
};
Console.WriteLine(gameStarting.ToScript());
}
}
public class DarkAgeGathererPercentages : Collection<SetGathererRate>
{
private readonly SetGathererRate[] assignVillagers = new SetGathererRate[] {
// SetGathererRate(total,food, wood, gold, stone)
new SetGathererRate( 3, 3, 0, 0, 0),
new SetGathererRate( 4, 4, 0, 0, 0),
new SetGathererRate( 5, 5, 0, 0, 0),
new SetGathererRate( 6, 6, 0, 0, 0),
new SetGathererRate( 7, 6, 1, 0, 0),
new SetGathererRate( 8, 6, 2, 0, 0),
new SetGathererRate( 9, 6, 3, 0, 0),
new SetGathererRate(10, 6, 4, 0, 0),
new SetGathererRate(11, 7, 4, 0, 0),
new SetGathererRate(12, 8, 4, 0, 0),
new SetGathererRate(13, 9, 4, 0, 0),
new SetGathererRate(14,10, 4, 0, 0),
new SetGathererRate(15,11, 4, 0, 0),
new SetGathererRate(16,12, 4, 0, 0),
new SetGathererRate(17,12, 5, 0, 0),
new SetGathererRate(18,12, 6, 0, 0),
new SetGathererRate(19,12, 7, 0, 0),
new SetGathererRate(20,12, 8, 0, 0),
new SetGathererRate(21,12, 9, 0, 0),
};
public DarkAgeGathererPercentages()
{
foreach (var item in assignVillagers) {
Add(item);
}
}
}
}
Then, it will output the following AI script.
;===============================================================================
;description: Init
; [total:3 F3, W0, G0, S0]
; [total:4 F4, W0, G0, S0]
; [total:5 F5, W0, G0, S0]
; [total:6 F6, W0, G0, S0]
; [total:7 F6, W1, G0, S0]
; [total:8 F6, W2, G0, S0]
; [total:9 F6, W3, G0, S0]
; [total:10 F6, W4, G0, S0]
; [total:11 F7, W4, G0, S0]
; [total:12 F8, W4, G0, S0]
; [total:13 F9, W4, G0, S0]
; [total:14 F10, W4, G0, S0]
; [total:15 F11, W4, G0, S0]
; [total:16 F12, W4, G0, S0]
; [total:17 F12, W5, G0, S0]
; [total:18 F12, W6, G0, S0]
; [total:19 F12, W7, G0, S0]
; [total:20 F12, W8, G0, S0]
; [total:21 F12, W9, G0, S0]
;===============================================================================
;[total:3 F3, W0, G0, S0]
(defrule
(unit-type-count villager == 3) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 100) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 0) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:4 F4, W0, G0, S0]
(defrule
(unit-type-count villager == 4) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 100) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 0) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:5 F5, W0, G0, S0]
(defrule
(unit-type-count villager == 5) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 100) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 0) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:6 F6, W0, G0, S0]
(defrule
(unit-type-count villager == 6) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 100) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 0) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:7 F6, W1, G0, S0]
(defrule
(unit-type-count villager == 7) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 86) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 14) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:8 F6, W2, G0, S0]
(defrule
(unit-type-count villager == 8) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 75) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 25) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:9 F6, W3, G0, S0]
(defrule
(unit-type-count villager == 9) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 67) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 33) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:10 F6, W4, G0, S0]
(defrule
(unit-type-count villager == 10) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 60) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 40) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:11 F7, W4, G0, S0]
(defrule
(unit-type-count villager == 11) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 64) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 36) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:12 F8, W4, G0, S0]
(defrule
(unit-type-count villager == 12) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 67) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 33) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:13 F9, W4, G0, S0]
(defrule
(unit-type-count villager == 13) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 69) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 31) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:14 F10, W4, G0, S0]
(defrule
(unit-type-count villager == 14) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 71) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 29) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:15 F11, W4, G0, S0]
(defrule
(unit-type-count villager == 15) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 73) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 27) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:16 F12, W4, G0, S0]
(defrule
(unit-type-count villager == 16) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 75) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 25) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:17 F12, W5, G0, S0]
(defrule
(unit-type-count villager == 17) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 71) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 29) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:18 F12, W6, G0, S0]
(defrule
(unit-type-count villager == 18) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 67) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 33) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:19 F12, W7, G0, S0]
(defrule
(unit-type-count villager == 19) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 63) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 37) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:20 F12, W8, G0, S0]
(defrule
(unit-type-count villager == 20) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 60) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 40) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)
;[total:21 F12, W9, G0, S0]
(defrule
(unit-type-count villager == 21) ;Check count : unit villager
=>
(set-strategic-number sn-food-gatherer-percentage 57) ;food_gatherer_percentage
(set-strategic-number sn-wood-gatherer-percentage 43) ;wood_gatherer_percentage
(set-strategic-number sn-gold-gatherer-percentage 0) ;gold_gatherer_percentage
(set-strategic-number sn-stone-gatherer-percentage 0) ;stone_gatherer_percentage
(disable-self)
)