Example #1
0
    //assumes that list of clues is sorted in ascending order by time
    public static LocationClue GetOriginClue(List <LocationClue> clues, float murderTime)
    {
        int          i    = 0;
        LocationClue clue = null;

        // Case 1: Empty clue list
        if (clues.Count < 1)
        {
            return(null);
        }
        // Case 2: No clues before the murder
        if (clues[i].timeInt > murderTime)
        {
            return(null);
        }
        // Case 3: Return the closest clue before the murder
        while (i < clues.Count && clues[i].timeInt < murderTime)
        {
            i++;
        }
        if (i > 0)
        {
            clue = clues[i - 1];
        }
        else
        {
            clue = clues[i];
        }
        return(clue);
    }
    public void AddLocationClue(LocationClue clue)
    {
        int       candidateID = clue.agentID;
        Candidate candidate   = candidates[candidateID];

        candidate.locationClues.Add(clue);
    }
    private Path CalculateScore(Candidate candidate)
    {
        List <LocationClue> clues = candidate.IncorporateOtherClues();

        if (clues.Count < 2)
        {
            return(null); //if we do not have more than two location clues about this candidate
        }
        float        score       = 0;
        float        murderTime  = GameController.GetInstanceTimeController().GetMurderTime();
        int          murderZone  = GameController.GetInstanceLevelController().GetMurderZone();
        LocationClue origin      = LocationClue.GetOriginClue(clues, murderTime);
        LocationClue destination = LocationClue.GetDestinationClue(clues, murderTime);

        if (origin == null || destination == null)
        {
            return(null); //not enough information about the agent either before or after the murder
        }

        List <ZoneInfo> zones = GameController.GetInstanceLevelController().GetZoneInfos();

        ZoneInfo start = zones[origin.zoneID]; //set the starting zone to origin

        int[] prev = FindPath(start, zones.Count);
        Path  originToMurderZone = Path.CreatePath(prev, murderZone, origin.zoneID, murderTime, origin.timeInt);

        start = zones[murderZone]; //set the starting zone to murder zone
        prev  = FindPath(start, zones.Count);
        Path murderZoneToDest = Path.CreatePath(prev, destination.zoneID, murderZone, destination.timeInt, murderTime);

        Path combinedPath = Path.CombinePaths(originToMurderZone, murderZoneToDest);
        //calculating actual time elapsed from origin to destination
        float timeElapsed = destination.timeInt - origin.timeInt;

        //how close is the score of the path compared to the actual time elapsed
        //will show us how likely the candidate took a path going through the murder zone
        score = 100 - (Mathf.Abs(combinedPath.GetScore() - timeElapsed));
        combinedPath.SetScore(score);
        return(combinedPath);
    }
Example #4
0
    //assumes that list of clues is sorted in ascending order by time
    public static LocationClue GetDestinationClue(List <LocationClue> clues, float murderTime)
    {
        int          i    = clues.Count - 1;
        LocationClue clue = null;

        // Case 1: Empty clue list
        if (clues.Count < 1)
        {
            return(null);
        }
        // Case 2: No clues after the murder
        if (clues[i].timeInt < murderTime)
        {
            return(null);
        }
        // Case 3: Return the closest clue after the murder time
        while (i >= 0 && clues[i].timeInt > murderTime)
        {
            i--;
        }
        clue = i == 0? clues[i]:clues[i + 1];
        //Debug.Log("Destination clue chosen: "+clue.ToString());
        return(clue);
    }
Example #5
0
 public static float CmpTime(LocationClue obj, LocationClue other)
 {
     return(obj.timeInt - other.timeInt);
 }
Example #6
0
 public void AddLocationClue(LocationClue clue)
 {
     locationClues.Add(clue);
 }