Tic-Tac-Toe Artificial Intelligences & Student Responsibility
Note: I think the last bit of this post will be interesting to most of you in a general sense, even if you don’t teach computer science.
I wanted my kids to do something more interactive with each other in programming. Up until now the kids have basically just been working on projects that I’ve come up with. They’ve added their own little variations, but in general I’ve orchestrated the whole thing (chagrin). My goal with the course has been to introduce genuinely interesting projects that have way more than one functioning solution. I really impress on my kids that this course is not about making the code “work,” it is about planning and thinking of an elegant solution to a problem that could be solved any number of inelegant ways.
For instance, I have them program a battleship clone. This turns out to be heavy on arrays. I know it may sound simple to those of you who are well versed — and are probably way more experienced CS teachers than myself — but my kids have a great and difficult time trying to organize and shuffle all of the information necessary to run this simple game.
Next, I wanted something where the kids could play each other. Battleship was nominally two player. By that I mean two kids could sit down and take turns clicking at the same machine. I wanted to foster the idea of communication via the Internet between programs so I came up with this idea: Battling Tic-Tac-Toe Artificial Intelligences. The kids would write a program that could assess the state of a game and then make a good next move. This information would then need to be stored on a server for their opponent’s AI to go and get in order to make a move. The kids loved it. We ended up making a big deal out of it. We had a bracket system, there were prizes, the whole school filled out brackets online. This was probably borderline ethically (gambling), but hey, I’m generally toeing the line with instructional activities as it is (my room has been on fire more than once).
My style in programming is to present the idea of the end product with a few concrete demands. Everything else is up to the kid. My demands were:
- The AI must always make a legal move.
- The AI must store the game state in a standard format in a file available to the other AI.
- The AI must function autonomously from the programmer.
So, my first question for all of you is: Is this good pedagogy? I’m admittedly green in the CS department. How are projects presented? Is this project-based model out of date? I’d love to hear how assignments and the like are handled in others’ programming courses.
The kids used about 5 days in class to program their AI’s. This was exciting. Many kids were quite secretive about how their program would select the best move. Many kids had crushing realizations that their program had to be smart enough to play both X’s and O’s. Which required a whole lot more programming for offense vs. defense.
The day of the tournament came and the kids chose sweet names for their AI’s (i.e.: Super Purple Pony Squadron, Var_Dump). Things went alright. Some kids obviously didn’t finish and had to forfeit. Some of the kids that were picked to win the whole tournament were knocked out in the first round via some fatal error in their programming logic. There was moderate buzz around the building, which means that programming itself was getting some much need PR. It was great to see how different approaches fared in the tournament. The basic approaches were:
- Play purely defense: always look for a block
- Play purely randomly. (this was pretty much punting on 4th and 20 for the kids who couldn’t finish on time)
- Use logic to play offense and defense, just like a human.
- Play sequentially: place left-right, top-bottom
An AI of type 3 won the tournament, but an AI of type 4 got all the way to the finals. There was pizza, revelry, and smack talk. My kind of classroom. At one point there was a wave and some chanting. Here’s a screen shot of the Tic-Tac-Toctagon:
Here’s what I liked about the lesson/project:
- The end result was social
- There was no road map to the end result (not that road maps are common for me.)
- The project involved the whole school
Teaching Responsibility (!= Grading It)
I was presented with one challenge: the students who didn’t meet the deadline of tournament day. How was I going to deal with their embarrassment at forfeiting? How should I grade them? How is my Standards-Based system going to incorporate participating in the tournament?
I thought to myself, “What standards are wrapped up in this project?” Arrays, Looping, Logic, and File System Mechanics. These are what I want this project to assess, the tournament is sort of just a carrot out in front. Do I really want their grade to be altered by their performance in something that’s supposed to be fun and silly? No. I decided that tournament participation would have to have nothing to do with their grade. I graded the unfinished projects against my standards just like the finished projects.
On the day of the tournament I decided that having to admit that they had to forfeit was a necessary evil. I don’t really love putting high schoolers in embarrassing situations, but I think that being eliminated from something fun is a great way to teach the great (unstated) responsibility lesson. It’s not going to ruin your grade, but it’s still going to suck that you decided not to put the work in to get this thing done. So, some kids had to forfeit, and they didn’t like it. Some kids who thought they had the best programs had to forfeit due to overlooking some small avenues. This was a great lesson. However, I refuse, I mean I absolutely refuse to let something as arbitrary as this lower a kid’s grade. Many of them have a deep understanding of programming, but messed up one little if/else statement on game day. Should there really be “points” for participation? No. In the end, I feel forfeiting taught responsibility in a way grades could never even hope to approximate.
Each pile of source code came in, flooding my inbox. I graded each one for elegance, use of arrays, use of logic and flow control, etc. All my standards. What the students get is feedback about what they have done, instead of just negative points about not being able to compete. The students also see concrete — yet dynamic — grades for the central themes in programming, instead of “TicTacToe AI: 40/60.” Honestly, what would that even mean? Did they compete poorly? Did their AI not work? Did it work, but cheat? I can’t even imagine regressing back to the summative-obsessed model. Have I ever mentioned that I love Standards-Based Grading?