void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Start)
     {
         startTime = time;
     }
     else if (phase == RunPhase.Goal)
     {
         endTime = time;
         float runTime = endTime - startTime;
         if (GeneralManager.HasRunRecord())
         {
             uiRecords.ShowRunnerResult(runTime, GeneralManager.GetRunTimeRecord());
         }
         else
         {
             uiRecords.ShowRunnerResult(runTime);
         }
         if (GeneralManager.IsPersonalRunRecord(runTime))
         {
             GeneralManager.SetRunRecord(runTime);
         }
         GeneralManager.RecentRunTime = runTime;
     }
 }
Example #2
0
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Goal)
     {
         StartCoroutine(ShowNav());
     }
 }
Example #3
0
 void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Start)
     {
         startTime = time;
     }
     else if (phase == RunPhase.Goal)
     {
         endTime = time;
         float score = this.score;
         if (GeneralManager.HasBirdRunRecord())
         {
             uiRecords.ShowBirdRunnerResult(score, GeneralManager.GetBirdRunRecord());
         }
         else
         {
             uiRecords.ShowBirdRunnerResult(score);
         }
         if (GeneralManager.IsPersonalBirdRunRecord(score))
         {
             GeneralManager.SetBirdRunRecord(score);
         }
         GeneralManager.RecentRunBirdingXRunning = score;
     }
 }
        /// <summary>
        ///     Generates bitmap images depicting the path for all successful trials during a given batch.
        /// </summary>
        /// <param name="baseDirectory">The base directory into which write images.</param>
        /// <param name="experimentName">The name of the experiment being analyzed.</param>
        /// <param name="experimentId">The ID of the experiment being analyzed.</param>
        /// <param name="run">The run during which the trial took place.</param>
        /// <param name="batch">The batch during which the trial took place.</param>
        /// <param name="evaluationUnits">The maze/agent combinations to trace.</param>
        /// <param name="runPhase">The run phase (initialization or primary) for the current set of trials.</param>
        public static void GenerateBitmapsForSuccessfulTrials(string baseDirectory, string experimentName,
            int experimentId, int run,
            int batch, IList<MazeNavigatorEvaluationUnit> evaluationUnits, RunPhase runPhase)
        {
            // Construct the output directory path
            string outputDirectory = Path.Combine(baseDirectory, experimentName,
                string.Format("Run {0}", run), "Trajectories", runPhase.ToString(), string.Format("Batch {0}", batch));

            // Create the output directory if it doesn't yet exist
            if (Directory.Exists(outputDirectory) == false)
            {
                Directory.CreateDirectory(outputDirectory);
            }

            // Generate bitmap images for each maze/navigator combination that resulted in a successful trial
            Parallel.ForEach(evaluationUnits.Where(unit => unit.IsMazeSolved),
                delegate(MazeNavigatorEvaluationUnit evaluationUnit)
                {
                    GenerateSingleMazeTrajectoryImage(
                        Path.Combine(outputDirectory,
                            string.Format("{0}_ExperimentID_{1}_Run_{2}_Batch_{3}_MazeID_{4}_NavigatorID_{5}.bmp",
                                experimentName, experimentId, run, batch, evaluationUnit.MazeId, evaluationUnit.AgentId)),
                        evaluationUnit.MazePhenome, evaluationUnit.AgentTrajectory);
                });
        }
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Start)
     {
         currentStartTime = time;
         bool             show  = GeneralManager.HasRun();
         SpriteRenderer[] rends = GetComponentsInChildren <SpriteRenderer>();
         for (int i = 0; i < rends.Length; i++)
         {
             rends[i].enabled = show;
         }
     }
     else if (phase == RunPhase.Goal)
     {
         currentGoalTime = time;
         float currentTime = currentGoalTime - currentStartTime;
         if (GeneralManager.IsPersonalRunRecord(currentTime))
         {
             GeneralManager.SetRunRecording(currentRun);
         }
         currentRun.Clear();
         SpriteRenderer[] rends = GetComponentsInChildren <SpriteRenderer>();
         for (int i = 0; i < rends.Length; i++)
         {
             rends[i].enabled = false;
         }
     }
 }
Example #6
0
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Goal)
     {
         reachedGoal = true;
         StartCoroutine(ShowUI(2f));
     }
 }
Example #7
0
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Start)
     {
         running = true;
     }
     else if (phase == RunPhase.Goal)
     {
         running = false;
     }
 }
Example #8
0
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Start)
     {
         running             = true;
         uiPaceMeter.running = true;
     }
     else
     {
         running             = false;
         uiPaceMeter.running = false;
     }
 }
Example #9
0
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Start)
     {
         running = true;
         StartCoroutine(gps());
     }
     else if (phase == RunPhase.Goal)
     {
         if (OnGPS != null)
         {
             OnGPS(transform.position);
         }
         running = false;
     }
 }
 private void HandleRunEvent(RunPhase phase, float time)
 {
     if (phase == RunPhase.Goal)
     {
         observing = false;
         if (GeneralManager.HasBirdingRecord())
         {
             uiRecords.ShowBirderResult(score, GeneralManager.GetBirdingRecord());
         }
         else
         {
             uiRecords.ShowBirderResult(score);
         }
         if (GeneralManager.IsPersonalBirdingRecord(score))
         {
             GeneralManager.SetBirdingRecord(score);
         }
         GeneralManager.RecentRunBirding = score;
     }
 }
Example #11
0
        /// <summary>
        ///     Generates bitmap images depicting the path for all successful trials during a given batch.
        /// </summary>
        /// <param name="baseDirectory">The base directory into which write images.</param>
        /// <param name="experimentName">The name of the experiment being analyzed.</param>
        /// <param name="experimentId">The ID of the experiment being analyzed.</param>
        /// <param name="run">The run during which the trial took place.</param>
        /// <param name="batch">The batch during which the trial took place.</param>
        /// <param name="evaluationUnits">The maze/agent combinations to trace.</param>
        /// <param name="runPhase">The run phase (initialization or primary) for the current set of trials.</param>
        /// <param name="startEndPointSize">The size of the start and end location points (optional).</param>
        /// <param name="trajectoryPointSize">The size of a point on the agent's trajectory (optional).</param>
        public static void GenerateBitmapsForSuccessfulTrials(string baseDirectory, string experimentName,
                                                              int experimentId, int run, int batch, IList <MazeNavigatorEvaluationUnit> evaluationUnits, RunPhase runPhase,
                                                              int startEndPointSize = 10, int trajectoryPointSize = 3)
        {
            // Construct the output directory path
            string outputDirectory = Path.Combine(baseDirectory, experimentName,
                                                  string.Format("Run {0}", run), "Trajectories", runPhase.ToString(),
                                                  batch != 0 ? string.Format("Batch {0}", batch) : "");

            // Create the output directory if it doesn't yet exist
            if (Directory.Exists(outputDirectory) == false)
            {
                Directory.CreateDirectory(outputDirectory);
            }

            // Evaluate only one successful agent trial per distinct maze
            // (otherwise, there would be millions of generated images)
            var distinctMazeEvaluationUnits =
                evaluationUnits.Where(eu => eu.IsMazeSolved).GroupBy(eu => eu.MazeId).Select(eu => eu.First()).ToList();

            // Generate bitmap images for each maze/navigator combination that resulted in a successful trial
            Parallel.ForEach(distinctMazeEvaluationUnits,
                             delegate(MazeNavigatorEvaluationUnit evaluationUnit)
            {
                GenerateSingleMazeTrajectoryImage(
                    Path.Combine(outputDirectory,
                                 batch != 0
                                ? string.Format("{0}_ExperimentID_{1}_Run_{2}_Batch_{3}_MazeID_{4}_NavigatorID_{5}.bmp",
                                                experimentName, experimentId, run, batch, evaluationUnit.MazeId,
                                                evaluationUnit.AgentId)
                                : string.Format("{0}_ExperimentID_{1}_Run_{2}_MazeID_{3}_NavigatorID_{4}.bmp",
                                                experimentName, experimentId, run, evaluationUnit.MazeId, evaluationUnit.AgentId)),
                    evaluationUnit.MazePhenome, evaluationUnit.AgentTrajectory, startEndPointSize,
                    trajectoryPointSize);
            });
        }
Example #12
0
 /// <summary>
 ///     Generates bitmap images depicting the path for all successful trials during a given batch.
 /// </summary>
 /// <param name="baseDirectory">The base directory into which write images.</param>
 /// <param name="experimentName">The name of the experiment being analyzed.</param>
 /// <param name="experimentId">The ID of the experiment being analyzed.</param>
 /// <param name="run">The run during which the trial took place.</param>
 /// <param name="evaluationUnits">The maze/agent combinations to trace.</param>
 /// <param name="runPhase">The run phase (initialization or primary) for the current set of trials.</param>
 /// <param name="startEndPointSize">The size of the start and end location points (optional).</param>
 /// <param name="trajectoryPointSize">The size of a point on the agent's trajectory (optional).</param>
 public static void GenerateBitmapsForSuccessfulTrials(string baseDirectory, string experimentName,
                                                       int experimentId, int run, IList <MazeNavigatorEvaluationUnit> evaluationUnits, RunPhase runPhase,
                                                       int startEndPointSize = 10, int trajectoryPointSize = 3)
 {
     GenerateBitmapsForSuccessfulTrials(baseDirectory, experimentName, experimentId, run, 0, evaluationUnits,
                                        runPhase, startEndPointSize, trajectoryPointSize);
 }
Example #13
0
 public void UpdateRunPhase(RunPhase runPhase)
 {
     // Nothing to be done for the file logger
 }