|
|
(49 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
| ==Turtle in a Pond Activity== | | ==Turtle in a Pond Activity== |
| | | |
− | Turtle in a Pond is a strategy game. The goal is to surround the turtle before it runs of the screen.
| + | Read at https://help.sugarlabs.org/turtle_in_a_pond.html |
| | | |
− | [[File:Turtle-in-a-pond.png|300px]]
| + | The source file has been moved to [https://github.com/godiard/help-activity/blob/master/source/turtle_in_a_pond.rst GitHub] |
− | | |
− | === How to play Turtle in a Pond ===
| |
− | | |
− | Did you know that:
| |
− | * You can load your own strategy for the turtle
| |
− | | |
− | ==== The Toolbars ====
| |
− | | |
− | [[Image:TurtlePond_toolbar-1.png]]
| |
− | | |
− | :from left to right
| |
− | # the Activity toolbar button
| |
− | # the New Game button
| |
− | # the Load new strategy button
| |
− | # the Reload the default strategy button
| |
− | # the Stop button
| |
− | | |
− | === Strategy ===
| |
− | | |
− | The default strategy is simple: choose a random direction and go there if the dot is open.
| |
− | <pre>
| |
− | def _turtle_strategy(self, turtle):
| |
− | c = turtle[1] % 2
| |
− | n = int(uniform(0, 6))
| |
− | for i in range(6):
| |
− | col = turtle[0] + CIRCLE[c][(i + n) % 6][0]
| |
− | row = turtle[1] + CIRCLE[c][(i + n) % 6][1]
| |
− | if not self._dots[self._grid_to_dot((col, row))].type:
| |
− | return [col, row]
| |
− | return turtle
| |
− | </pre>
| |
− | | |
− | In this version, the turtle will go off the edge if it can.
| |
− | <pre>
| |
− | def _turtle_strategy(self, turtle):
| |
− | c = turtle[1] % 2
| |
− | for i in range(6):
| |
− | col = turtle[0] + CIRCLE[c][i][0]
| |
− | row = turtle[1] + CIRCLE[c][i][1]
| |
− | if self._dots[self._grid_to_dot((col, row))].type is None:
| |
− | return [col, row]
| |
− | | |
− | n = int(uniform(0, 6))
| |
− | for i in range(6):
| |
− | col = turtle[0] + CIRCLE[c][(i + n) % 6][0]
| |
− | row = turtle[1] + CIRCLE[c][(i + n) % 6][1]
| |
− | if not self._dots[self._grid_to_dot((col, row))].type:
| |
− | return [col, row]
| |
− | return turtle
| |
− | </pre>
| |
− | | |
− | The dots are stored in a 13x13 array. Each dot has an attribute, 'type', that determines it status. The edges have a type=None. Occupied dots have a type=True. Unoccupied dots have a type=False.
| |
− | | |
− | | |
− | === Where to get Turtle in a Pond ===
| |
− | | |
− | The Turtle in a Pond activity is available for download from the [http://activities.sugarlabs.org Sugar activity portal]: [http://activities.sugarlabs.org/en-US/sugar/addon/4516 Turtle in a Pond]
| |
− | | |
− | The source code is available on [http://git.sugarlabs.org/turtlepond the Sugar Labs Gitorious server].
| |
− | | |
− | [[Category:Activity]]
| |