Beispiel #1
0
    public void ExchangeClues()
    {
        Agent     otherAgent = agentToTalkTo.GetComponent <Agent>();
        Candidate c1         = agent.solver.GetLeastKnownCandidate();
        Candidate c2         = otherAgent.solver.GetLeastKnownCandidate();

        //destroy old hovering texts to prevent duplicate hovertext gameobjects from spawning
        Destroy(agent.talkingState);
        Destroy(otherAgent.talkingState);
        //add a hovertext to denote exchange of information
        agent.talkingState = Instantiate(agent.blankHoverText, gameObject.transform);
        agent.talkingState.GetComponent <TextMesh>().text = string.Format("{0}", c1.agentID);
        otherAgent.talkingState = Instantiate(otherAgent.blankHoverText, otherAgent.gameObject.transform);
        otherAgent.talkingState.GetComponent <TextMesh>().text = string.Format("{0}", c2.agentID);
        //store old knowledge base somewhere for visual purposes
        Solver    thisAgentSolver  = agent.solver;
        Solver    otherAgentSolver = otherAgent.solver;
        Candidate oldC1            = new Candidate(c1.agentID);

        oldC1.locationClues = oldC1.IncorporateOtherClues();
        thisAgentSolver.oldCandidateInfo[(c1.agentID)].Add(oldC1);
        Candidate oldC2 = new Candidate(c2.agentID);

        oldC2.locationClues = oldC2.IncorporateOtherClues();
        otherAgentSolver.oldCandidateInfo[(c2.agentID)].Add(oldC2);
        //add new clues
        c1.AddOtherClues(otherAgent.solver.candidates[c1.agentID].locationClues, otherAgent.agentId);
        c2.AddOtherClues(agent.solver.candidates[c2.agentID].locationClues, agent.agentId);
        Debug.Log("Facts Exchanged");

        agentToTalkTo.GetComponent <KnowledgeBase>().lastAgentSpokenTo = gameObject;
        lastAgentSpokenTo = agentToTalkTo;
    }