/// <summary> /// Creates random new LifeEvent /// </summary> /// <returns>Stack of LifeEvent for Environment</returns> private Stack <EnviroEvent> MakeEvents() { Stack <EnviroEvent> result = new Stack <EnviroEvent>(); // There is 30 % probability of new event int val = Core.rn.Next(10); if (val >= 3) { return(result); } else { // I will create 3 events maximally while (val < 3) { EnviroEventType type = (EnviroEventType)val; int when = DayOfLife + Core.rn.Next(7) + Core.rn.Next(7); EnviroEvent ev; switch (type) { case EnviroEventType.HomeWork: ev = new HomeworkEnviroEvent(when); Log($"Homework in {when-DayOfLife} days"); break; case EnviroEventType.Test: ev = new TestEnviroEvent(when, LastBestKnowladge); Log($"Test in {when - DayOfLife} days"); break; case EnviroEventType.PublicEvent: ev = new PublicEnviroEvent(when); Log($"Public free-time event in {when - DayOfLife} days"); break; default: throw new NotImplementedException("Unknown EviroEvent type"); } result.Push(ev); val = Core.rn.Next(9); } return(result); } }
/// <summary> /// Proceed examination on the end of semester /// </summary> public void SimulateExams() { Log("--- Examination period started ---"); EnviroEvent le = new TestEnviroEvent(DayOfLife + Core.DAYS_IN_WEEK, LastBestKnowladge); foreach (Student student in students) { int backup = student.Gens.LengthOfPlanning; student.Gens.LengthOfPlanning = student.Gens.LengthOfPlanning * 2 > Core.DAYS_IN_WEEK ? Core.DAYS_IN_WEEK : student.Gens.LengthOfPlanning * 2; le.Plan(student); student.Gens.LengthOfPlanning = backup; student.LiveDay(0); } for (int i = 0; i < Core.DAYS_IN_WEEK; i++) { Log("--- " + Core.DAYS[DayOfLife % Core.DAYS_IN_WEEK] + " ---"); foreach (Student student in students) { student.LiveDay(0); } DayOfLife++; } }