/// <summary> /// Initializes the wator world. /// </summary> /// <param name="settings"> /// The settings. /// </param> private void InitializeWatorWorld(IWatorSettings settings) { currentSharkPopluation = settings.InitialSharkPopulation; currentFishPopluation = settings.InitialFishPopulation; this.IsEndReached = false; this.Round = 0; this.WatorWorld = new WatorWorld(settings); }
/// <summary> /// Initializes a new instance of the <see cref="Phase"/> class. /// </summary> /// <param name="world"> /// The world. /// </param> /// <param name="blackPhase"> /// if set to <c>true</c> then this represents /// the black phase (even phase) otherwise whitephase (odd phase). /// </param> public Phase(WatorWorld world, bool blackPhase = false) { this.world = world; this.BlackPhase = blackPhase; this.initialRun = true; // set number for phase workers this.InitializeWorkerNumber(); // createa events for control of workers this.InitializeConcurrencyEvents(); // create the workers this.InitializeWorkers(); }
/// <summary> /// Initializes a new instance of the <see cref="PhaseExecutionWorker"/> class. /// </summary> /// <param name="world"> /// The world. /// </param> /// <param name="workerId"> /// The worker identifier. /// </param> /// <param name="startRow"> /// The worker start row. /// </param> /// <param name="endRow"> /// The worker end row. (inclusive) /// </param> /// <param name="eventGo"> /// The event go. /// </param> /// <param name="eventBarrier"> /// The event barrier. /// </param> /// <param name="eventReady"> /// The event ready. /// </param> public PhaseExecutionWorker( WatorWorld world, int workerId, int startRow, int endRow, ManualResetEventSlim eventGo, ManualResetEventSlim eventBarrier, CountdownEvent eventReady) { this.workerId = workerId; this.World = world; this.StartRow = startRow; this.EndRow = endRow; this.worldWidth = world.Settings.WorldWidth; this.eventGo = eventGo; this.eventReady = eventReady; this.eventBarrier = eventBarrier; // create and start task this.InitializeTask(); }