/**
  * @return array
  */
 public function getNewCellStateForDeadCellProvider()
 {
     $data = [];
     // x, y, expected state
     $data[] = [0, 2, State::letRest()];
     $data[] = [0, 3, State::letRest()];
     $data[] = [0, 4, State::letRest()];
     $data[] = [1, 4, State::letRest()];
     $data[] = [2, 1, State::resurrect("xx")];
     $data[] = [2, 3, State::resurrect("yy")];
     $data[] = [3, 0, State::letRest()];
     $data[] = [3, 1, State::letRest()];
     $data[] = [3, 2, State::letRest()];
     $data[] = [4, 0, State::letRest()];
     $data[] = [4, 1, State::letRest()];
     $data[] = [4, 2, State::letRest()];
     $data[] = [4, 3, State::letRest()];
     $data[] = [4, 4, State::letRest()];
     return $data;
 }
예제 #2
0
 /**
  * @param array $neighboursCount
  * @return State
  */
 private function getDeadCellNewState(array $neighboursCount)
 {
     foreach ($neighboursCount as $species => $count) {
         //			If there are exactly three organisms of one type surrounding one element, they may
         //			give birth into that cell. The new organism is the same type as its parents. If this
         //			condition is true for more then one species on the same element then species type
         //			for the new element is chosen randomly.
         if ($count == 3) {
             return State::resurrect($species);
         }
     }
     return State::letRest();
 }