Activities/Turtle in a Pond: Difference between revisions

Line 129: Line 129:
<pre>
<pre>
def _turtle_strategy(self, turtle):
def _turtle_strategy(self, turtle):
    dots = self._surrounding_dots(turtle)
     dots_ordered_by_weight = self._ordered_weights(turtle)
     dots_ordered_by_weight = self._ordered_weights(turtle)
     for i in range(6):
     if self._dots[dots_ordered_by_weight[0]].type is None:
        self._orientation = dots.index(dots_ordered_by_weight[i])
        return self._dot_to_grid(dots_ordered_by_weight[0])
        if self._daylight_ahead(turtle):
     elif not self._dots[dots_ordered_by_weight[0]].type:
            return self._dot_to_grid(dots[self._orientation])
        return self._dot_to_grid(dots_ordered_by_weight[0])
 
     else:
    n = int(uniform(0, 6))
        return turtle
     for i in range(6):
        if not self._dots[dots[(i + n) % 6]].type:
            self._orientation = (i + n) % 6
            return self._dot_to_grid(dots[(i + n) % 6])
     self._orientation = (i + n) % 6
    return turtle
</pre>
</pre>