Open main menu
Home
Random
Log in
Settings
About Sugar Labs
Disclaimers
Sugar Labs
Search
Changes
← Older edit
Newer edit →
Activities/Turtle in a Pond
(view source)
Revision as of 16:28, 1 December 2011
222 bytes removed
,
16:28, 1 December 2011
→Strategy
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>
Walter
Bureaucrats
,
Administrators
10,579
edits