-
Notifications
You must be signed in to change notification settings - Fork 0
01 Add conditions
Satoshi Teshiba edited this page Jan 17, 2021
·
2 revisions
In the Dark age, it is necessary to limit training villagers for research next Feudal age.
To train up to 24 villagers in the Dark age, write the following C # code.
using System;
using LibAoe2AISharp.Framework;
using LibAoe2AISharp.Specifications;
using static LibAoe2AISharp.Specifications.Ope;
namespace Aoe2AISharpSample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new TrainVillager(25).ToScript());
}
}
public class TrainVillager : Train
{
public TrainVillager(int count)
: base(unit.villager)
{
Facts.Add(new unit_type_count_total(unit.villager, relop.lt, count));
Facts.Add(new current_age(relop.eq, age.dark_age));
}
}
}
Then, it will output the following AI script.
;Train villager
(defrule
(can-train villager) ;Can train villager?
(unit-type-count-total villager < 25) ;Check count : unit villager
(current-age == dark-age) ;Check dark-age
=>
(train villager) ;Train villager
)