May 19th lesson

31 views
Skip to first unread message

Cameron McEfee

unread,
May 6, 2012, 11:35:13 AM5/6/12
to coderdoj...@googlegroups.com
Hi Guys,

How are we doing on a lesson plan for May 19th. Did we decide who's going to be writing/teaching?

Cameron

Kevin Clark

unread,
May 6, 2012, 7:50:08 PM5/6/12
to coderdoj...@googlegroups.com
I'm doing it. Was planning on building on tic tac toe. Will have
something more concrete in the next couple days.

--
Sent from my phone

Kevin Clark

unread,
May 12, 2012, 5:50:22 PM5/12/12
to coderdoj...@googlegroups.com, sf-code...@googlegroups.com
Ok, updates on this:

I'm working through a lesson plan right now, partially based on the
tic tac toe lesson from before. The goal will be to get them writing a
simple AI so that they can play against the computer. It'll all center
around them writing a single function that takes the state of the
world and returns the space number that the computer 'chooses'. Basic
code is here:

https://github.com/kevinclark/Lesson-Plans/blob/master/tic-tac-toe-2/tictactoe2.py

I'm working through it with my guinea pig now, and I'll have step by
step stuff up in the .md file in the next couple hours.

The big new concepts for this class will be dictionaries and if
statements. We'll review for loops and lists as well.

I'm going to try to organize the seating arrangement so that those new
to the group or who need more help can be in front and expect to work
in lock-step. Those who feel confident already should have lots of
room to experiment on their own, and can do more of a 1-1 thing with
mentors in the back of the room.

I'm also taking us back to IDLE for the dev environment - turns out
it's got a text editor and it's really easy to get that code going in
the interpreter. We can avoid having multiple windows and the terminal
completely.


--
Kevin Clark
http://glu.ttono.us

Kevin Clark

unread,
May 12, 2012, 11:34:17 PM5/12/12
to coderdoj...@googlegroups.com, sf-code...@googlegroups.com
This is largely complete - the last step for the lesson plan is to
allow the computer to make random moves. I'm hacking it up
momentarily. Feel free to send in critiques here, or for the github
savvy, I happily accept pull requests.

https://github.com/kevinclark/Lesson-Plans/blob/master/tic-tac-toe-2/tic-tac-toe-2.md

Aaron VonderHaar

unread,
May 15, 2012, 11:40:03 PM5/15/12
to coderdoj...@googlegroups.com
Github is giving me a 404 when I try to edit the file, but there is a
typo on line 124: "takeTurn" should instead be "take_turn", otherwise
the game crashes after you enter a space to play in.
--
--Aaron V.
[ http://github.com/avh4 ]

Aaron VonderHaar

unread,
May 15, 2012, 11:51:22 PM5/15/12
to coderdoj...@googlegroups.com
Apart from the typo I mentioned, it looks pretty good!

Two suggestions:
- Maybe passing three separate params to computer_player(xs, os,
empties) would be preferable to passing a world dictionary simply for
the fact that the syntax is simpler (no matching square brackets and
single quotes required) so the kids will have to think less to be able
to play around with it. Lower cognitive workload is good for
encouraging creativity and experimentation!
- Maybe the engine should throw an exception when the computer
chooses a space that's not empty?

Cheers,
--Aaron

Kevin Clark

unread,
May 16, 2012, 9:31:15 PM5/16/12
to coderdoj...@googlegroups.com
Typo fixed, thanks!

On Tue, May 15, 2012 at 8:51 PM, Aaron VonderHaar
<gruen0...@gmail.com> wrote:
> Apart from the typo I mentioned, it looks pretty good!
>
> Two suggestions:
>  - Maybe passing three separate params to computer_player(xs, os,
> empties) would be preferable to passing a world dictionary simply for
> the fact that the syntax is simpler (no matching square brackets and
> single quotes required) so the kids will have to think less to be able
> to play around with it.  Lower cognitive workload is good for
> encouraging creativity and experimentation!

I'm passing a dict because I wanted a basic example of one so I could
introduce the concept. Otherwise I think the only new concept is 'if'.
I figured the square brackets were similar enough to those used with
lists, so it wouldn't be much of a hurdle. I'm interested in hearing
other opinions on this though. Will sleep on it myself.

Also, it shouldn't require single quotes - is there a place where I
imply that? Or maybe I'm using them inconsistently and not noticing?


>  - Maybe the engine should throw an exception when the computer
> chooses a space that's not empty?

I went back and forth on this. Initially I thought I should disallow
it, but if I don't, and they make the mistake, it gives them an
opportunity to figure out what's going wrong without the computer
saying it outright. I was also curious what would happen if I gave
them an environment where they could write a computer player that
cheats :) Seemed like it might be fun when they discovered it.

But that might be more complicated than is useful.

Thoughts?
Reply all
Reply to author
Forward
0 new messages