本文整理汇总了C#中State.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# State.AddItem方法的具体用法?C# State.AddItem怎么用?C# State.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State.AddItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LimitDepthFirstPlanSearch
public void LimitDepthFirstPlanSearch()
{
var state = new State();
state.AddItem("Cash", 0);
var action = new PlanningAction("Get Salary").Produces("Cash",100);
state.PlanningActions.Add(action);
var g0 = new Goal("Accumulate Cash").Target("Cash", 1000);
IPlan p = new DFSPlan().SetMaxSearchDepth(3);
p.Search(state, g0);
Assert.That(p.GetPath().Count, Is.EqualTo(3));
}
示例2: DontPerformAnyActionWhenNoActionIsAvailable
public void DontPerformAnyActionWhenNoActionIsAvailable()
{
var state = new State();
state.AddItem("Cash", 99);
var action = new PlanningAction("Not affordable").Consumes("Cash", 100).Produces("Harvester");
state.PlanningActions.Add(action);
var g0 = new Goal("Build Harvester").Target("Harvester", 1);
IPlan p = new DFSPlan();
p.Search(state, g0);
Assert.That(p.GetPath().ToList().Count, Is.EqualTo(0));
}
示例3: Execute
public void Execute(State s)
{
foreach (var c in _consumes)
{
s.ReduceItem(c.Key, c.Value);
}
if (multiProducer)
{
int quantity = s.ItemQuantity(_requires.Keys.First());
foreach (var p in _produces)
{
s.AddItem(p.Key, p.Value * quantity);
}
}
else
{
foreach (var p in _produces)
{
s.AddItem(p.Key, p.Value);
}
}
_postActions.ForEach(pa => pa(s));
}