blob: 221928c65369bcdf8a4e4be6be28a45177d35e0d (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
\section{Your First Bot}
\fasttrack{Always move up.}
Alright, let’s get started.
If you think back to when you started programming, chances are the first program
you ever wrote was one which printed out the immortal phrase “Hello World”.
Well we can’t print stuff here, but our first bot is going to be almost as
useless as that: our bot is just going to continually move up.
Let’s have a look at the code:
\pythonfile{firstbot.py}
If you run this script (\texttt{python firstbot.py}),
you should see a nice big board with some apples scattered over it, and a snake
continually moving upwards.
That snake is our bot: each time the game decides that our snake is allowed to
move, it calls the \texttt{up\_bot} function, which immediately returns the
string \mint{python}|'U'|, which means it should move the snake upwards.
Got all that?
Once you’re ready, we’ll move on to something a little more interesting.
|