Mercurial > rinkhals
comparison gamelib/animal.py @ 71:00cf9d7f22dc
Expand comment
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Mon, 31 Aug 2009 22:20:27 +0000 |
parents | d92a2f973cc4 |
children | aa4bd93575d9 |
comparison
equal
deleted
inserted
replaced
70:d92a2f973cc4 | 71:00cf9d7f22dc |
---|---|
113 # We calculate the cost of the direct path | 113 # We calculate the cost of the direct path |
114 direct_path = self._gen_path(self.pos, final_pos) | 114 direct_path = self._gen_path(self.pos, final_pos) |
115 min_cost = self._cost_path(direct_path, gameboard) | 115 min_cost = self._cost_path(direct_path, gameboard) |
116 min_path = direct_path | 116 min_path = direct_path |
117 # is there a point nearby that gives us a cheaper direct path? | 117 # is there a point nearby that gives us a cheaper direct path? |
118 # This is delibrately not finding the optimal path, as I don't | |
119 # want the foxes to be too intelligent, although the implementation | |
120 # isn't well optimised yet | |
118 poss = [Position(x, y) for x in range(self.pos.x - 2, self.pos.x + 3) | 121 poss = [Position(x, y) for x in range(self.pos.x - 2, self.pos.x + 3) |
119 for y in range(self.pos.y - 2, self.pos.y + 3)] | 122 for y in range(self.pos.y - 2, self.pos.y + 3)] |
120 for start in poss: | 123 for start in poss: |
121 if start == self.pos: | 124 if start == self.pos: |
122 continue # don't repeat work we don't need to | 125 continue # don't repeat work we don't need to |