Ejemplo n.º 1
0
        protected override bool DidTrainingUnitComplete(ref bool wasUnitSuccessful)
        {
            if (SchoolWorld.IsEmulatingUnitCompletion())
            {
                return(SchoolWorld.EmulateIsTrainingUnitCompleted(out wasUnitSuccessful));
            }
            else
            {
                m_stepsSincePresented++;

                if (DidTrainingUnitFail())
                {
                    wasUnitSuccessful = false;
                    return(true);
                }

                if (!m_teacher.IsDone() && m_agent.IsMoving())
                {
                    wasUnitSuccessful = false;
                    return(true);
                }

                // save history for agent and teacher
                m_agentsHistory.Add(m_agent.Position.X, m_agent.Position.Y);
                m_teachersHistory.Add(m_teacher.Position.X, m_teacher.Position.Y);

                wasUnitSuccessful = false;

                int numberOfTeachersSteps = m_teachersHistory.numberOfSteps();
                int numberOfAgentsSteps   = m_agentsHistory.numberOfSteps();

                // simple version of the task
                if (TSHints[STOP_REQUEST] == .0f)
                {
                    if (numberOfTeachersSteps == numberOfAgentsSteps && m_teacher.IsDone())
                    {
                        // compare step
                        wasUnitSuccessful = m_teachersHistory.CompareTo(m_agentsHistory, m_stepsSincePresented);
                        return(true);
                    }
                }
                // hard version
                else
                {
                    if (numberOfTeachersSteps == numberOfAgentsSteps && m_teacher.IsDone())
                    {
                        m_delayedCheck = true;
                    }

                    if (m_delayedCheck)
                    {
                        m_delayedCheck = false;
                        // compare steps
                        wasUnitSuccessful = m_teachersHistory.CompareTo(m_agentsHistory, m_stepsSincePresented);
                        return(true);
                    }
                }
                return(false);
            }
        }
Ejemplo n.º 2
0
        public override void PresentNewTrainingUnit()
        {
            CreateAgent();
            CreateTeacher();

            m_stepsSincePresented = 0;
            m_agentsHistory       = new AgentsHistory();
            m_agentsHistory.Add(m_agent.Position.X, m_agent.Position.Y);
            m_teachersHistory = new AgentsHistory();
            m_teachersHistory.Add(m_teacher.Position.X, m_teacher.Position.Y);
        }