Example #1
0
 def _update_frame(self):
     new_frame = constant_frame()
     new_frame[1:8] = self._frame[0:7]
     new_frame[0] = self._update_life(self._frame[0]) * MAX_INTENSITY
     if not np.any(new_frame[0]):
         new_frame[0] = self._initial_population() * MAX_INTENSITY
     self._frame = new_frame
Example #2
0
    def next_frame(self):
        if self._stepper.step():
            if self._move_time <= 0:
                self._move_time = random() * self.SECONDS_MAX_MOVE_WINDOW
                for i in range(self.DOTS_TO_MOVE):
                    random_dot = int(floor(random() * self.DOTS))
                    if self._dot_velocity[random_dot] == 0:
                        self._dot_velocity[random_dot] = 0.5 if self._dot_height[random_dot] is 0 else -0.5
            for i in range(self.DOTS):
                self._dot_height[i] = int(self._dot_height[i] + self._dot_velocity[i])
                self._dot_velocity[i] *= 1.2
                if self._dot_height[i] > 7:
                    self._dot_height[i] = 7
                    self._dot_velocity[i] = 0
                elif self._dot_height[i] < 0:
                    self._dot_height[i] = 0
                    self._dot_velocity[i] = 0
            self._move_time -= self.SECONDS_PER_STEP

            self._frame = constant_frame()
            indexes_to_update = zip(self._dot_height,
                                    [j[0] for j in self._dot_grid],
                                    [j[1] for j in self._dot_grid])
            for index in indexes_to_update:
                self._frame[index] = MAX_INTENSITY
        return self._frame
Example #3
0
 def setup(self, fps):
     self._frame = constant_frame()
     self._frame[0][0][0] = MAX_INTENSITY
     self._frame[0][0][7] = MAX_INTENSITY
     self._frame[0][7][0] = MAX_INTENSITY
     self._frame[0][7][7] = MAX_INTENSITY
     self._frame[7][0][0] = MAX_INTENSITY
     self._frame[7][0][7] = MAX_INTENSITY
     self._frame[7][7][0] = MAX_INTENSITY
     self._frame[7][7][7] = MAX_INTENSITY
Example #4
0
 def setup(self, fps, number_of_worms=1):
     """ Initialize worms. The head is always the last item in the list
     :param fps:
     :param number_of_worms:
     :return:
     """
     self._stepper = TimeStepper(self.SECONDS_PER_STEP)
     self._frame = constant_frame()
     self._worms = []
     for worm in range(number_of_worms):
         self._worms.append(self._setup_worm())
     for worm in self._worms:
         self._frame[worm.head_x()][worm.head_y()][worm.head_z()] = \
             Worm.WORM_INTENSITY
Example #5
0
 def setup(self, fps):
     self._stepper = TimeStepper(self.SECONDS_PER_STEP)
     self._step_count = 0
     self._dot_grid = list(itertools.product(
         range(8), range(8)
     ))
     self._dot_height = [0] * self.DOTS
     self._dot_velocity = [0] * self.DOTS
     self._move_time = random() * self.SECONDS_MAX_MOVE_WINDOW
     random_heights = range(self.DOTS)
     shuffle(random_heights)
     random_heights = random_heights[len(random_heights) / 2:]
     for height in random_heights:
         self._dot_height[height] = 7
     self._frame = constant_frame()
Example #6
0
 def setup(self, fps):
     self._stepper = TimeStepper(self.SECONDS_PER_STEP)
     self._step_count = 0
     self._index = list(itertools.product(range(8), range(8), range(8)))
     self._frame = constant_frame()
Example #7
0
 def setup(self, fps):
     self._frame = constant_frame(MAX_INTENSITY)
Example #8
0
 def setup(self, fps):
     self._stepper = TimeStepper(self.SECONDS_PER_STEP)
     self._frame = constant_frame()
     self._frame[0] = self._initial_population() * MAX_INTENSITY
     self._neighbours = np.array([[i, j] for i in (-1, 0, 1)
                                  for j in (-1, 0, 1) if i != 0 or j != 0])