tron tourney 2
I'm feeling that I haven't provided enough
structure for all of you to get off the ground.
Here's some explicit instructions for csmarlboro :
how to make and run your own bot
1. Get to terminal or Git Bash shell
2. ssh to csmarlboro
$ ssh testerator@csmarlboro.org # put your username, not testerator
3. make your own copy of all the tron stuff. (notice the ".", means "here")
csmarlboro:~$ scp -r /var/www/csmarlboro/tron .
csmarlboro:~$ ls -sCF
4 site/ 4 stuff/ 4 tron/ tron_logfile.txt
4. change to that directory
csmarlboro:~$ cd tron/
csmarlboro:tron$ ls -sCF
4 bots/ 4 games/ 4 lib/ 4 logs/ 8 README.md 4 run*
4 engines/ 4 index.html 4 LICENSE 4 maps/ 4 replay/ 4 tournaments/
5. make a copy of a bot
csmarlboro:tron$ ls -sCF bots/
... bunch of stuff
csmarlboro:tron$ cp bots/northbot.py bots/testerator.py # pick a name
6. edit that bot
csmarlboro:tron$ nano bots/testerator.py
... and change it. Or upload your own python code.
7. test it manually.
csmarlboro:tron$ bots/testeratory.py < bots/input.txt
...
8. watch it run against another bot by editing ./run
csmarlboro:tron$ nano run
... change which bots or which room
csmarlboro:tron$ less run # show the run file
...
./engines/round.py --FPS=5 -v -B maps/empty-room.txt bots/randbot.py bots/testerator.py
9. see if it runs.
csmarlboro:tron$ ./run
debugging
I put in a lot more docs and debugging help
into the github repo over the weekend,
and sent you some email?
Read what's in
and see the example log stuff in
I'm guessing that we may well want to talk
about how to go about debugging something
that doesn't work. Anybody who writes code
spends much of their time puzzling out
what went wrong ... and so learning the
strategies and how to play the game is
a very real part of learning to program.
Volunteers to show us code that doesn't work?
Testing :
- How would you try it on a bigger room?
- Or with a game that's already in progress?
- Can you automate trying your bot in several rooms?
- Can you modify the infrastructure to give it a room *without* doing all the stdin, stdout stuff?
API :
- If you don't like the methods in tron.py, what would make more sense?
Help :
- How often should you ask for assistance? How?
Discuss stdin, stdout, redirection and all that.
algorithms
Last week I suggested that this would be our next topic.
So ...
- what sorts of things would you like the bot to know?
- how can we get that from the map?
algorithm tools:
- data structures (primitive ones depend on the language) and their API
- python
- strings :list of characters, but can't modify
- tuple : immutable list: (1,2,3))
- lists [] : .append(thing), .pop(), map(func, list), len(list), ...)
- sets :like lists, but no duplicate entries)
- dictionaries {} ; key:value collections
- looping over a collection
- graphs ? (not built in) (We did graph search in algorithms class)
- programming patterns
- accumulator pattern : building up result piece by piece
- find biggest : or smallest : initialize, loop, save if bigger
- recursion : redo task on next part; know when to stop)
Often there is a close connection between
an algorithm and the data structures that
store its calculations. Thinking about what
information is needed at each step can be helpful.
Functions - breaking the task into smaller pieces ... which can mean making your own "API"
Objects / classes - assembling data & methods into nice abstractions.
Well known algorithms :