blob: 36b7382f347ec656cab4daf35c42a3a145162f98 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
\section{Closest apple}
One interesting bot we can write is one which always moves towards the closest
apple. Both the idea and the coding are a little tricky, but see if you can
handle it. In order to find the closest apple, we actually want to know
the \emph{shortest path} to the apple, and when we know that, the first step in
that path is the direction we need to move in.
To find the shortest path, we need to use an algorithm called
\emph{breadth first search} (BFS).
% TODO: description of the algorithm
\pythonfile{closest_apple.py}
|