当前位置: 首页>>代码示例>>C#>>正文


C# WorldState.Set方法代码示例

本文整理汇总了C#中WorldState.Set方法的典型用法代码示例。如果您正苦于以下问题:C# WorldState.Set方法的具体用法?C# WorldState.Set怎么用?C# WorldState.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorldState的用法示例。


在下文中一共展示了WorldState.Set方法的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);
        }
    }
开发者ID:garrafote,项目名称:unity3d-goap,代码行数:61,代码来源:GOAPTestV1.cs


注:本文中的WorldState.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。