Exemple #1
0
 def _point_or_random(self, options):
     if 'point' in options:
         point = Point(options['point'][0], options['point'][1],
                       self._config['dim'])
     else:
         point = Point.random(self._config['dim'])
     return point
Exemple #2
0
 def __init__(self, size=None, point=None):
     # growth rate based on extra food / food deficiency
     self._GROWTH_RATE = 0.1
     # maintanence multiplier to size
     self._MAINTANENCE_RATE = 0.1
     # max food multiplier to size
     self._MAX_FOOD_RATE = 1
     # number of cycles that the bug can live
     self._AGE_LIMIT = 100
     # if current_size / expected_size_ratio * age < MIN_SIZE_RATIO, bug will
     # die because it's too thin.
     self._MIN_SIZE_RATIO = 0.5
     self.age = 0
     self.id = uuid.uuid4()
     if point == None:
         self.point = Point.random()
     else:
         self.point = point
     self._SIZE_AGE_RATIO = 1
     self._size = size
     self.DIRS = [
         Vector(v[0], v[1]) for v in ((0, 1), (1, 1), (1, 0), (1, -1),
                                      (0, -1), (-1, -1), (-1, 0), (-1, 1))
     ]
     self._vision = [0] * 8
     self.dir = self.DIRS[0]
     self.is_on_food = False
     self.food_supply = 0
Exemple #3
0
    def __init__(self, size=None, point=None, age=None):
        # growth rate based on extra food / food deficiency
        self._GROWTH_RATE = 0.1
        # maintanence multiplier to size
        self._MAINTANENCE_RATE = 0.1
        # max food multiplier to size
        self._MAX_FOOD_RATE = 1
        # number of cycles that the bug can live
        self._AGE_LIMIT = 100
        # each bug will have a random uuid
        self.id = uuid.uuid4()
        # initialize bug status
        self.size = size if size else 0
        self.point = point if point else Point.random()
        self.age = age if age else 0

        self.DIRS = [
            Vector(v[0], v[1]) for v in ((0, 1), (1, 1), (1, 0), (1, -1),
                                         (0, -1), (-1, -1), (-1, 0), (-1, 1))
        ]
        self._vision = [0] * 8
        self.dir = self.DIRS[0]
        self.is_on_food = False
        self.food_supply = 0
Exemple #4
0
 def set_random_point(self):
     self.point = Point.random()