-
Notifications
You must be signed in to change notification settings - Fork 0
02 Research rule
Satoshi Teshiba edited this page Jan 15, 2021
·
3 revisions
Villagers become stronger by researching loom.
The research should be completed in the Dark age.
In the Dark Age, to research "loom" when the villager count becomes seven or villager cannot be trained, 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 ResearchLoom(7).ToScript());
}
}
public class ResearchLoom : Research
{
public ResearchLoom(short villagerCount)
: base(ri.loom)
{
Facts.Add(
new current_age(relop.eq, age.dark_age),
!new can_train(unit.villager)
| new unit_type_count(unit.villager, relop.ge, villagerCount)
);
}
}
}
Then, it will output the following AI script.
;Research loom
(defrule
(can-research ri-loom) ;Can research loom?
(current-age == dark-age) ;Check dark-age
(or
(not (can-train villager)) ;Can train villager?
(unit-type-count villager >= 7) ;Check count : unit villager
)
=>
(research ri-loom) ;Research loom
)