finish words - Feb 4
Discuss your homework : github, anagrams, and palindromes
See the code at:
Or maybe you'll like this :
Getting set up with github:
Things to consider (or reconsider):
- What sorts of debugging and testing did you do?
- Can someone looking at what you submitted do that too?
- Did you give an explicit example of what your code does when it runs?
- Did you give instructions on how to run it? And what it needs to run?
- Did you google "palindrome algorithm" or "anagram example"?
- Does your code need to be fast? Is it?
tron
Start talking about the Tron robot challenge.
The original materials, explanations, and "starter packages" are at
I've uploaded an engine that runs the bots to github which is also on csmarlboro in the /var/www/csmarlboro/tron folder
Here's how you can copy the files to your folder
and run it on csmarlboro :
laptop$ ssh user@csmarlboro.org # where user=your_username
csmarl$ scp -r /var/www/csmarlboro/tron . # copy the tron folder to here.
csmarl$ cd tron # go into that new folder
csmarl$ ./run # run two bots against each other
Or you can clone or download the github repo.
I'll walk through how the thing works,
and describe the python robot examples.
Essentially :
- an engine (referee) program runs two robots in a room
- the room files are just text ; look in maps/ for examples
- each robot program communicates by stdio (read) and stdout (write).
- On each turn, the robot reads a room, and writes a number 1 to 4 for (N,E,S,W)
Running a robot manually, for example, could look like this:
$ ./MyTronBot.py | You type the stuff on the left.
5 4 < It reads: width height of board
##### < north wall
#1 2# < 1 is bot; 2 is opponent
# # <
##### < south wall
2 > It writes this: move 1 east
5 4 < Then it reads the next board;
##### < same format. Walls appear
##1## < where the bots were.
# 2# <
##### <
3 > It writes the only legal move: south
and so on. The bots move simultaneously. If both move
to the same spot, it's a draw. If your bot makes an
illegal move, or takes too long (about a second),
you forfeit the game. If you do make a legal move
but they don't (if they are boxed in, for example)
then you win.
The tron.py package can handle the input/output for
you, and gives you an API for finding out what's
where on the board. You'll need to read the source
and/or look at the bots for examples to see how
it works.
There are several engines (including a tournament
engine which runs a bunch of players in a bunch
of rooms), and one that saves a game file
that can be replayed through a web browser.
If you want to use their Java engine (included in the starter packages):
2. From the command line
$ cd python # the python starter package
$ ls
COPYING engine/ freebot.py* northbot.py* tron.py
MyTronBot.py* example_bots/ maps/ randbot.py* wallbot.py*
$ java -jar engine/Tron.jar maps/empty.txt ./MyTronBot.py ./MyTronBot.py
That should run (in glorious ascii art) those two bots in that room, on the terminal.
The python bot uses the definitions in the tron.py file to do the tricky stuff.
To write your own first robot, look at wallbot.py, northbot.py, and randbot.py, and adapt according to your own thinking ...
Things to think about:
- How do you debug something which needs to print only moves?
- If it needs time to think, how do you ensure a timely move?
- What are winning strategies?
- And what do you need to figure out about the board?