Example #1
0
 public override bool Apply(Project p, Worker w)
 {
     if (Event.random.NextDouble() <= chance)
     {
         Triggered(p, w);
         return true;
     }
     return false;
 }
Example #2
0
 /// <summary>
 /// This method decides whether to apply the event to this worker,
 /// based on worker, environment, and external factors.
 /// </summary>
 /// <param name="w"></param>
 /// <returns></returns>
 public virtual bool Apply(Project p, Worker w)
 {
     return false;
 }
Example #3
0
 public abstract void Triggered(Project p, Worker w);
Example #4
0
        /// <summary>
        /// Applies effort to reduce total remaining work on the project.
        /// May choose to do nothing, either once, or permanently.
        /// </summary>
        /// <param name="project"></param>
        public void Work(Project project)
        {
            // currentCapability has been altered by events, use it as it is
            currentCapability *= efficiency;
            project.completedWorkUnits += (int)currentCapability;

            // now reset capability
            currentCapability = baseCapabilityPerDay;
        }
Example #5
0
 public override void Triggered(Project p, Worker w)
 {
     w.currentCapability *= effect;
     p.log.Add("Worker " + w.name + " was " + logline + " on day " + p.stepsTaken + ".");
 }
Example #6
0
 public override void Triggered(Project p, Worker w)
 {
     w.currentCapability *= effect;
     int left = 0;
     if (affected.ContainsKey(w))
         left = affected[w].daysLeft;
     left = length - left;
     p.log.Add("Worker " + w.name + " was " + logline + " (" + left + "/" + length + ") on day " + p.stepsTaken + ".");
 }
Example #7
0
 public override bool Apply(Project p, Worker w)
 {
     // we check first whether this worker is already affected
     if (affected.ContainsKey(w))
     {
         Memo memo = affected[w];
         memo.daysLeft--;
         if (memo.daysLeft <= 0)
             affected.Remove(w);
         Triggered(p, w);
     }
     else if (Event.random.NextDouble() <= chance)
     {
         int leave = length - 1;
         affected.Add(w, new Memo(leave));
         Triggered(p, w);
         return true;
     }
     return false;
 }
Example #8
0
 public int Simulate(Project p)
 {
     int steps = 0;
     while (!p.Finished)
     {
         p.Step();
         steps++;
     }
     //System.Console.Out.WriteLine(STEPS_NAME + "s taken to complete project: " + steps);
     return steps;
 }
Example #9
0
        public void go()
        {
            Config config = new Config(projectConfigFileName);
            List<Project> statistics = new List<Project>();
            List<Event> events = EventInitializer.getEvents(config);
            Int32 targetRuns = config.getValue<Int32>("Runs");

            for (int i = 0; i < targetRuns; i++)
            {
                Project p = new Project(config);
                p.possibleEvents = events;

                Simulate(p);
                statistics.Add(p);
            }
            Analyze(statistics);
        }