///// <summary>
 ///// Function to give a random change to return true; 
 ///// </summary>
 ///// <param name="probability">Probability to give true = 1 / probability.</param>
 ///// <returns></returns>
 //public bool rollDice(int probability)
 //{
 //    int goAgain = differentSeedRandom.Next(probability);
 //    return goAgain == probability - 1;
 //}
 public void addRandomReplaySteps(Scenario currentScenario)
 {
     if (previousWasOffline)
     {
         addOnlineSteps(differentSeedRandom.Next(1, maxConsequentOnlineEvents), currentScenario);
         previousWasOffline = false;
     }
     else
     {
         addOfflineSteps(differentSeedRandom.Next(maxConsequentOfflineEvents), currentScenario);
         previousWasOffline = true;
     }
 }
 public ScenarioAnalyser(Scenario scenario)
 {
     currentScenario = scenario;
     analyseScenario();
 }
 public ScenarioAnalyser(string scenarioLocation)
 {
     RandomScenarioGenerator randGen = new RandomScenarioGenerator();
     currentScenario = (Scenario)randGen.FileToObject(scenarioLocation);
     analyseScenario();
 }
 private void addOnlineSteps(int amount, Scenario currentScenario)
 {
     for (int i = 0; i < amount; i++)
     {
         IEvent toUse = generatedEvents.ElementAt(currentEvent);
         currentEvent++;
         currentScenario.addOnlineReplayStep(new OnlineReplayStep(toUse));
         scenariolength++;
         totalEvents++;
     }
 }
        private void addOfflineSteps(int amount, Scenario currentScenario)
        {
            // Offline events are generated seperately, as to not affect the online event list, to keep it random.
            Generator offlineGenerator = new Generator(generatedEvents.GetRange(0, currentEvent));

            List<IEvent> offlineEvents = offlineGenerator.generateRandomEvents(amount);

            List<IEvent> onlineEvents = generatedEvents.GetRange(currentEvent, amount);
            currentEvent += amount;

            for (int i = 0; i < amount; i++)
            {
                OfflineReplayStep offlineStep = new OfflineReplayStep(onlineEvents.ElementAt(i), offlineEvents.ElementAt(i));
                currentScenario.addOfflineReplayStep(offlineStep);
                scenariolength++;
                totalEvents += 2;
            }
        }
        public Scenario generateRandomScenario(int length)
        {
            // Need to times the length of the replayevents because offline steps contain 2 events.
            generatedEvents = eventGenerator.generateRandomEvents(length * 2);

            Scenario generatedScenario = new Scenario();

            while (totalEvents < (length - 1))
            {
                addRandomReplaySteps(generatedScenario);
            }

            // Add a final online event to make the scenario commit its last offline events.
            generatedScenario.addOnlineReplayStep(new OnlineReplayStep(new ListNameChanged("Final List")));
            return generatedScenario;
        }