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


C# Agent.resetPercepts方法代码示例

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


在下文中一共展示了Agent.resetPercepts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getPercepts

    // Agent perceives world through this function alone.
    public void getPercepts(Agent agent, float perfectVisionRange)
    {
        float startTime = Time.realtimeSinceStartup;
        agent.resetPercepts();

        AgentPercept tempPercept;

        List<Agent> nearbyAgents = new List<Agent>();
        Vector2 loc = agent.Location;
        float radius = agent.SightRange;
        Quad visibleArea = new Quad( loc.x-radius, loc.y-radius, loc.x+radius, loc.y+radius );

        agentTree.SearchArea(visibleArea, ref nearbyAgents);

        for(int i=0; i<nearbyAgents.Count; i++)
        {
            // For now not doing self-aware. No Skynet on *my* watch!
            if(agent.Guid == nearbyAgents[i].Guid)
            {
                continue;
            }
            if(canPerceivePosition(agent, nearbyAgents[i].Location, perfectVisionRange))
            {
                tempPercept 		= agent.getNextPercept();// new AgentPercept();
                tempPercept.type 	= AgentPercept.PerceptType.AGENT;
                tempPercept.locOne 	= nearbyAgents[i].Location;
                tempPercept.living 	= nearbyAgents[i].LivingState;
                tempPercept.facingDirection = nearbyAgents[i].Direction;

                // TODO: Agent object should not be part of percept, fix!
                // See AgentPercept.perceivedAgent for more.
                tempPercept.perceivedAgent = nearbyAgents[i];

                tempPercept 		= null;
            }
        }

        List<Rect> nearbyStructures = new List<Rect>();
        buildingTree.SearchArea(visibleArea, ref nearbyStructures);

        List<AgentPercept> structureList = null;
        for(int i=0; i<nearbyStructures.Count; i++)
        {
            perceiveStructure(agent, nearbyStructures[i]);
        }

        // TODO: Work out a smarter way to handle WorldObjects than point-based
        if(agent.Type == Agent.AgentType.HUMAN || agent.Type == Agent.AgentType.HUMAN_PLAYER)
        {
            for(int wo=0; wo<worldObjects.Count; wo++)
            {
                if(canPerceivePosition(agent, worldObjects[wo].Location, perfectVisionRange))
                {
                    tempPercept = agent.getNextPercept();// new AgentPercept();
                    tempPercept.type = AgentPercept.PerceptType.EXTRACT;
                    tempPercept.locOne = worldObjects[wo].Location;
                    tempPercept.living = AgentPercept.LivingState.INANIMATE;

                    tempPercept = null;
                }
            }
        }
        _perceptTotalTime += (Time.realtimeSinceStartup-startTime);
        _perceptTotalCount++;
    }
开发者ID:futurechris,项目名称:zombai,代码行数:66,代码来源:WorldMap.cs


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