tron debugging
Asides:
schedule
Last weekend for this round of individual efforts
- 2nd tournament will happen with bots as defined midnight next Wed - THAT'S A FIRM DEADLINE. Have your bot named username_bot (or a minor variation) in the github repo, or submit (or resubmit) in this week's homework.
- There will be a prize.
- There will be a grade for this one.
- Please have something, including some docs (in the same file is enough) describing it's approach.
Next week on Thu we'll look at the results. We will have one more class, next
For the two weeks after that (March 1 - 13) we'll do group collaborations, on one more tron tourney. New languages and/or approaches are recommended. If you have ideas for who you'd like to work with, let me know in this week's assignment. I'll assign teams next week. Tourney 3 will happen just before break, also for a grade.
After break we'll all start new projects. Be thinking about what you want to work on - more coming on what's appropriate. (And I'll have some suggestions if you don't have a specific thing in mind.)
Discussion
Discuss where you are with your bots.
- Help with debugging?
- Explain your code status?
- How have you been testing? (i.e. convincing yourself that your code and/or algorithm is valid?)
Here are the ways that you should be thinking about the problem:
- python doc tests - what tests are, why do them
- API - what they are, why they're important, their "docstrings" : 'what are the inputs & outputs'
- break the problem into small sub tasks
- test those parts individually
- automate the tests if possible
(Sound anything like my themes from last semester?)
testing & algorithms
Yesterday I put together test_tron.py as an example :
Depending on time and interest (and at the risk of too much "here's what I did"),
we can discuss what's there, namely (a) trying out tron.py and (b) flood fill.
My flood fill code illustrates several coding concepts :
- General purpose "loop over things" routine with function passed in
- Allowing several variations of what to calculate
- One of few uses of functions within functions in python
- Discuss "scope" : which functions can see which variables
- Discuss the idea of a "closure" - can be a trick concept in "how do scopes work", and varies in details by language. (compile time? run time?)
- The (somewhat strange) notion in Python of what is (and isn't) easily changeable for variables "outside" functions.
- Quick quiz: What would this look with recursion? (But really, python isn't all that good at recursion. Big function stacks. Limited depth, about 1000 without reset.)
- What is a "fringe"?
Last aside: this code measuring
python's recursion limit may be of interest for those of you who've been using recursion. The interesting thing here is how I measured it : exceptions, recursion, global variables (why use 'em here? alternatives?).