Exemple #1
0
    protected bool findNearestPercept(List <AgentPercept> percepts,
                                      AgentPercept.LivingState livingType,
                                      AgentPercept.PerceptType perceptType,
                                      out AgentPercept nearest)
    {
        float   targetDistance = float.MaxValue;
        Vector2 targetPosition = Vector2.zero;

        float tempDistance = 0.0f;

        nearest = null;

        for (int i = 0; i < percepts.Count; i++)
        {
            if (percepts[i].living == livingType && percepts[i].type == perceptType)
            {
                tempDistance = Vector2.Distance(percepts[i].locOne, _myself.Location);

                if (tempDistance < targetDistance)
                {
                    targetDistance = tempDistance;
                    targetPosition = percepts[i].locOne;
                    nearest        = percepts[i];
                }
            }
        }

        if (nearest != null)
        {
            return(true);
        }

        if (percepts.Count > 0)
        {
            // prefer to if-and-assign than to allocate.
            nearest = percepts[0];
            return(false);
        }

        nearest = new AgentPercept();
        return(false);
    }
Exemple #2
0
        // private DPLL dpll = new OptimizedDPLL();

        private void step(WumpusKnowledgeBase KB, AgentPercept percept, int t)
        {
            KB.tellTemporalPhysicsSentences(t);
            KB.makePerceptSentence(percept, t);
        }
Exemple #3
0
 protected bool findNearestAgent(List<AgentPercept> percepts, AgentPercept.LivingState livingType, out Agent foundAgent)
 {
     AgentPercept resultAgent;
     bool result = findNearestPercept(percepts, livingType, AgentPercept.PerceptType.AGENT, out resultAgent);
     if(result)
     {
         if(resultAgent.perceivedAgent != null)
         {
             foundAgent = resultAgent.perceivedAgent;
             return true;
         }
         else
         {
             foundAgent = new Agent();
             return false;
         }
     }
     else
     {
         foundAgent = new Agent();
         return false;
     }
 }
Exemple #4
0
    protected bool findNearestPercept(List<AgentPercept> percepts, 
	                                  AgentPercept.LivingState livingType,
	                                  AgentPercept.PerceptType perceptType,
	                                  out AgentPercept nearest)
    {
        float targetDistance = float.MaxValue;
        Vector2 targetPosition = Vector2.zero;

        float tempDistance = 0.0f;

        nearest = null;

        for(int i=0; i<percepts.Count; i++)
        {
            if(percepts[i].living == livingType && percepts[i].type == perceptType)
            {
                tempDistance = Vector2.Distance(percepts[i].locOne, _myself.Location);

                if( tempDistance < targetDistance)
                {
                    targetDistance = tempDistance;
                    targetPosition = percepts[i].locOne;
                    nearest = percepts[i];
                }
            }
        }

        if(nearest != null)
        {
            return true;
        }

        if(percepts.Count > 0)
        {
            // prefer to if-and-assign than to allocate.
            nearest = percepts[0];
            return false;
        }

        nearest = new AgentPercept();
        return false;
    }