本文整理汇总了C#中WorldState.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# WorldState.ToString方法的具体用法?C# WorldState.ToString怎么用?C# WorldState.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldState
的用法示例。
在下文中一共展示了WorldState.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
void Execute()
{
var planner = new ActionPlanner();
planner.Clear();
planner.SetPrecondition(Actions.Scout, Atoms.Alive, true);
planner.SetPostcondition(Actions.Scout, Atoms.EnemyVisible, true);
planner.SetPrecondition(Actions.Approach, Atoms.EnemyVisible, true);
planner.SetPostcondition(Actions.Approach, Atoms.NearEnemy, true);
planner.SetPrecondition(Actions.Aim, Atoms.EnemyVisible, true);
planner.SetPrecondition(Actions.Aim, Atoms.WeaponLoaded, true);
planner.SetPostcondition(Actions.Aim, Atoms.EnemyLinedUp, true);
planner.SetPrecondition(Actions.Shoot, Atoms.EnemyLinedUp, true);
planner.SetPostcondition(Actions.Shoot, Atoms.EnemyAlive, false);
planner.SetPrecondition(Actions.Load, Atoms.ArmedWithGun, true);
planner.SetPostcondition(Actions.Load, Atoms.WeaponLoaded, true);
planner.SetPrecondition(Actions.DetonateBomb, Atoms.ArmedWithBomb, true);
planner.SetPrecondition(Actions.DetonateBomb, Atoms.NearEnemy, true);
planner.SetPostcondition(Actions.DetonateBomb, Atoms.Alive, false);
planner.SetPostcondition(Actions.DetonateBomb, Atoms.EnemyAlive, false);
planner.SetCost(Actions.DetonateBomb, 5);
planner.SetPrecondition(Actions.Flee, Atoms.EnemyVisible, true);
planner.SetPostcondition(Actions.Flee, Atoms.EnemyVisible, false);
Debug.Log(planner.ToString<Actions, Atoms>());
var state = new WorldState();
state.Set(Atoms.EnemyVisible, false);
state.Set(Atoms.ArmedWithGun, true);
state.Set(Atoms.WeaponLoaded, false);
state.Set(Atoms.EnemyLinedUp, false);
state.Set(Atoms.EnemyAlive, true);
state.Set(Atoms.ArmedWithBomb, true);
state.Set(Atoms.NearEnemy, false);
state.Set(Atoms.Alive, true);
Debug.LogFormat("State: {0}", state.ToString<Atoms>());
var goal = new WorldState();
goal.Set(Atoms.EnemyAlive, false);
Debug.LogFormat("Goal: {0}", goal.ToString<Atoms>());
var search = new Fringe(Graph.PlannerHeuristic);
var stateNode = new WorldStateNode(planner, state);
var goalNode = new WorldStateNode(planner, goal);
var path = search.FindPath(stateNode, goalNode);
foreach (WorldStateNode node in path)
{
Debug.Log(node.State);
}
}