Mercurial > mamba
comparison mamba/snake.py @ 312:8a6ef789bd45
Cap at three moves, not two.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 16 Sep 2011 18:42:37 +0200 |
parents | 3b7288064935 |
children | cd544a311f11 |
comparison
equal
deleted
inserted
replaced
311:3b7288064935 | 312:8a6ef789bd45 |
---|---|
97 world.interact(segment) | 97 world.interact(segment) |
98 | 98 |
99 def send_new_direction(self, orientation): | 99 def send_new_direction(self, orientation): |
100 self._orientation_changes.append(orientation) | 100 self._orientation_changes.append(orientation) |
101 # Cap queue length: | 101 # Cap queue length: |
102 self._orientation_changes = self._orientation_changes[:2] | 102 self._orientation_changes = self._orientation_changes[:3] |
103 | 103 |
104 def _pop_orientation_queue(self): | 104 def _pop_orientation_queue(self): |
105 while self._orientation_changes: | 105 while self._orientation_changes: |
106 orientation = self._orientation_changes.pop(0) | 106 orientation = self._orientation_changes.pop(0) |
107 if ((0 == orientation[0] == self.head.orientation[0]) | 107 if ((0 == orientation[0] == self.head.orientation[0]) |