Changes

Line 45: Line 45:  
     c = turtle[1] % 2
 
     c = turtle[1] % 2
 
     for i in range(6):
 
     for i in range(6):
         col = turtle[0] + CIRCLE[c][i][0]
+
         column = turtle[0] + CIRCLE[c][i][0]
 
         row = turtle[1] + CIRCLE[c][i][1]
 
         row = turtle[1] + CIRCLE[c][i][1]
         if not self._dots[self._grid_to_dot((col, row))].type:
+
         if not self._dots[self._grid_to_dot((column, row))].type:
             return [col, row]
+
             return [column, row]
 
     return turtle
 
     return turtle
 
</pre>
 
</pre>
Line 58: Line 58:  
     c = turtle[1] % 2
 
     c = turtle[1] % 2
 
     for i in range(6):
 
     for i in range(6):
         col = turtle[0] + CIRCLE[c][i][0]
+
         column = turtle[0] + CIRCLE[c][i][0]
 
         row = turtle[1] + CIRCLE[c][i][1]
 
         row = turtle[1] + CIRCLE[c][i][1]
         if not self._dots[self._grid_to_dot((col, row))].type:
+
         if not self._dots[self._grid_to_dot((column, row))].type:
 
             self._orientation = i
 
             self._orientation = i
             return [col, row]
+
             return [column, row]
 
     return turtle
 
     return turtle
 
</pre>
 
</pre>
Line 73: Line 73:  
     n = int(uniform(0, 6))
 
     n = int(uniform(0, 6))
 
     for i in range(6):
 
     for i in range(6):
         col = turtle[0] + CIRCLE[c][(i + n) % 6][0]
+
         column = turtle[0] + CIRCLE[c][(i + n) % 6][0]
 
         row = turtle[1] + CIRCLE[c][(i + n) % 6][1]
 
         row = turtle[1] + CIRCLE[c][(i + n) % 6][1]
         if not self._dots[self._grid_to_dot((col, row))].type:
+
         if not self._dots[self._grid_to_dot((column, row))].type:
 
             self._orientation = (i + n) % 6
 
             self._orientation = (i + n) % 6
             return [col, row]
+
             return [column, row]
 
     return turtle
 
     return turtle
 
</pre>
 
</pre>
Line 87: Line 87:  
     c = turtle[1] % 2
 
     c = turtle[1] % 2
 
     for i in range(6):
 
     for i in range(6):
         col = turtle[0] + CIRCLE[c][i][0]
+
         column = turtle[0] + CIRCLE[c][i][0]
 
         row = turtle[1] + CIRCLE[c][i][1]
 
         row = turtle[1] + CIRCLE[c][i][1]
         if self._dots[self._grid_to_dot((col, row))].type is None:
+
         if self._dots[self._grid_to_dot((column, row))].type is None:
 
             self._orientation = i
 
             self._orientation = i
             return [col, row]
+
             return [column, row]
    
     n = int(uniform(0, 6))
 
     n = int(uniform(0, 6))
 
     for i in range(6):
 
     for i in range(6):
         col = turtle[0] + CIRCLE[c][(i + n) % 6][0]
+
         column = turtle[0] + CIRCLE[c][(i + n) % 6][0]
 
         row = turtle[1] + CIRCLE[c][(i + n) % 6][1]
 
         row = turtle[1] + CIRCLE[c][(i + n) % 6][1]
         if not self._dots[self._grid_to_dot((col, row))].type:
+
         if not self._dots[self._grid_to_dot((column, row))].type:
 
             self._orientation = (i + n) % 6
 
             self._orientation = (i + n) % 6
             return [col, row]
+
             return [column, row]
 
     return turtle
 
     return turtle
 
</pre>
 
</pre>
Line 113: Line 113:  
Your strategy should return a tuple containing the column and row of the new turtle position, e.g.,
 
Your strategy should return a tuple containing the column and row of the new turtle position, e.g.,
   −
  return [col, row]
+
  return [column, row]
    
There are some resources that you can use in your program, including:
 
There are some resources that you can use in your program, including:
   −
;CIRCLE: a 2x6x2 array of offsets that can used to find the column and row of the dots surrounding the turtle.
   
;self._dots: the array of dots.
 
;self._dots: the array of dots.
 
;self._pressed: the index of the most recent dot pressed by the user
 
;self._pressed: the index of the most recent dot pressed by the user
 
;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._dot_to_grid(dot): returns an array (column, row) representing the grid position of a dot
 +
;CIRCLE: a 2x6x2 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:
 +
 +
CIRCLE contains tuples of offsets (a column offset and a row offset) that allow you to find the grid coordinates (column and row) of the 6 dots that surround the turtle. It is complicated by the fact that the rows are staggered (in order to form hexagons) so when the turtle is on an even row (turtle[1] % 2 == 0) we use one set of offsets (CIRCLE[0]) and when it is on an odd row (turtle[1] % 2 == 1) we use a second set of offsets (CIRCLE[1]).
    
=== Where to get Turtle in a Pond ===
 
=== Where to get Turtle in a Pond ===