Activities/Turtle in a Pond: Difference between revisions
| Line 114: | Line 114: | ||
</pre> | </pre> | ||
The dots are stored in a | The dots are stored in a 13✕13 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. | ||
Your strategy should start with: | Your strategy should start with: | ||
| Line 128: | Line 128: | ||
There are some resources that you can use in your program, including: | There are some resources that you can use in your program, including: | ||
;self._dots: the array of dots. | ;self._dots: the array of dots from which you can test the type attribute (self._dots[i].type==None → edge; self._dots[i].type==False → open; self._dots[i].type==True → blocked) | ||
;self. | |||
;self._orientation:you can set the orientation of your turtle by assigning a number from 0-5 (clockwise beginning with 30 degrees from north) | ;self._orientation:you can set the orientation of your turtle by assigning a number from 0-5 (clockwise beginning with 30 degrees from north) | ||
;self._set_label('your message here'):you can write a message on the toolbar if you want to communicate what your turtle is thinking | ;self._set_label('your message here'):you can write a message on the toolbar if you want to communicate what your turtle is thinking | ||
;self._grid_to_dot((column, row)): returns the dot that is at a grid position (column, row) | ;self._grid_to_dot((column, row)): returns the dot that is at a grid position (column, row) | ||
;self._dot_to_grid(dot): returns an array (column, row) representing the grid position of a dot | ;self._dot_to_grid(dot): returns an array (column, row) representing the grid position of a dot | ||
;CIRCLE: a | ;CIRCLE: a 2✕6✕2 array of offsets that can used to find the column and row of the dots surrounding the turtle. | ||
A bit more explanation about the CIRCLE constant: | A bit more explanation about the CIRCLE constant: | ||