Unity and Some Thoughts On Homework

So today I decided to play around with Unity – it’s a professional game development environment. I worked through most of their 3D platformer tutorial and found making games to be pretty easy and fun: it’s definitely worth downloading (it’s free for PC/Web games) if you know programming and think making a game would be a neat project.

Now the (ostensible) reason I’m doing this is for a class (Handheld AR Game Design). The professor sort of told us to go through the Unity Tutorials. By “sort of” I mean that he told us to go through the Unity Tutorials, but then made it abundantly clear that he would not be checking to ensure we did do this. He also has an upcoming lecture about introducing us to Unity: that lecture could (in theory) rely on us having picked up the basics already and jump right into AR, but he never said that that was the case or that this lecture would be on a particular day.

So what we have is a recommended assignment. And just to be clear this is not a small thing: this tutorial I’m going through is 122 pages long. So I did it, mostly, and I found it cool. But I started to think: would it be better if it was assigned? Let me take a stab at pros and cons:

Pros

  1. Absolutely no work for the instructor (the niceness of this really can’t be overemphasized)
  2. Sets an expectation that students should be doing things for their own interest, not because they have to
  3. Lets students be flexible. I skipped some parts of the tutorial that was teaching me stuff I understood well; I will likely use that time to go back and explore some stuff I thought was particular interesting on my own

Cons

  1. Some students just won’t do it. Maybe that means it’s their fault but from a completely pragmatic perspective students who are behind hurt the whole class in a variety of ways.
  2. Make it “required” means that busy students have an excuse to do it. Certainly I can testify to the fact that, I felt more-or-less like I was slacking off as I went through this tutorial. As a converse to the above, maybe that feeling let me skip some sections that actually contained stuff I’d find helpful but I was too lazy to do.
  3. Can’t easily make assumptions about when it’s done, incorporate them into lesson planning

What would I do if it was my class? I think I’d assign it formally. The main issue for me is Con1: if it’s worth recommending, it’ll benefit the whole class to be able to rely on everyone knowing it. I’d try to mitigate Pro1 by making the check and the grade both perfunctory. I think Pro2 is nice in theory, but in all honestly “doing what your teacher told you to do” should not need to be a sign of taking learning initiative: if that’s the goal there a better ways to reward people for going above and beyond.

Anybody out there agree or disagree?

Intro to Jython Lecture: Reflections

I’m acting as an unofficial TA for an unusual course this semester: “Rapid Prototyping”. This is a course for students with non-CS background: the goal is to get them up to speed with the basics of quickly building UIs and other apps for research. It’s not a gentle introduction to programming; after half a class on loops, objects, data structures, etc the class move quickly into building Java (Jython UIs and a variety of other fairly tricky topics).

I got the opportunity to teach that “recap of all CS1 (in a different language you don’t know) + building UIs” course. Three hours to cover a great array of topics, going off slides that the main professor prepared. Even just keeping the students semi-conscious for 3 hours is definitely a bit of a challenge (thought these are all graduate students so it’s better).

What I did:

Part 1: Language Intro: The main things I thought about was trying to reach lower skilled students and keep everybody interested for the whole time.

I supplemented the existing sides with 8 exercises designed to highlight what I thought were tricky things. I used my usual “ghetto clicker” technique of having students hold up fingers to indicate solution 1 2 3 etc.

Pros. The initial activities did well: most students had to think a little but in the end most got them right. Plus after the questions I would tend to get a little flurry of questions to help clarify understandings even from the people who did get it. Coding ones seemed to work given the talking and the fact that we could contrast the syntax between correct and what they wrote. This (as usual) also got good feedback in the mini-surveys I passed out. Plus, just helped to break up the lessons a bit.

Cons. Questions about finding bugs proved a bit problematical – I think I need to make it concrete by labeling the lines and asking to pick which one has the bug. Also a problem was knowing when students are done…need a way to figure that out even with the ghetto clickers.

Part 2: Java UI basics: I wanted to keep things practical so I opted for live-coded examples + the original slides.

Pros: Generally this went pretty well and I could hear a little flurry of typing whenever I started so people seemed to be keeping up to type as I did. Might be possible to leverage this into a more hands on activity where not everything needs to be coming from me. Got one enthusiastic respond from my surveys.

Cons: Obviously took some time but I think it was well spent. Major issue here was just exhaustion on my part – 2.5 hours is a long lecture. I think I need to plan more carefully at the end…I tend to plan beginning to end which leaves the end a little weaker. Maybe the other way would be better.

Part 3: Random stuff and talking about the assignment: I followed the notes with this, but it was difficult because it was unclear exactly how things fit together, which stuff was more important. Maybe rushed a bit. I think we could easily have taken the “learn about the assignment stuff” offline…and gotten more time. But what would we have done? If I had to do this again I might have tried to put some longer coding thing in the middle so that both the students and myself would not be so tired at the endpoint.

My Slides!

Just Some Julia Sets

So one of the neat side things I learned at GHP was how the Mandelbrot Set works. Somehow I had the impression that the Mandelbrot Set was really complicated so I had never looked up the details. But it is really crazy-simple, assuming you know what a complex number is. Anyways, once I learned this, I just had to cook up my own mini-fractal generator and explore. I didn’t actually draw the Mandelbrot (yeah, now that I understand the Mandelbrot just doesn’t excite me anymore): I’m drawing some julia sets which are a very close relative.

And I did it in Processing which made it extra easy and fun.

class Cnum //complex number
{

    float r; //real
    float i; //imaginary
    Cnum(float r_, float i_) {
        r = r_;
        i = i_;
    }

    String irep()
    {
        return "[" + r + " + " + i + "i]";
    }

    String prep()
    {
        float theta = arg();
        float r2 = sqrt((i*i) + (r*r));
        return "[r=" + r2 + " theta=" + theta + "]";

    }

    String toString() {
        return irep();
    }

    boolean isInfinity()
    {
        return r == Float.POSITIVE_INFINITY;
    }

    boolean isZero()
    {
        return r == 0 && i == 0;
    }

    Cnum conj()
    {
        return new Cnum(r, i*-1);
    }

    Cnum neg()
    {
        return new Cnum(-r,-i);
    }

    float arg()
    {
	return atan2(i,r);
    }

    float abs()
    {
        return sqrt(r*r + i*i);
    }
} 	

Cnum add(Cnum a, Cnum b)
{
    return new Cnum(a.r + b.r, a.i + b.i);
}
Cnum sub(Cnum a, Cnum b)
{
    return new Cnum(a.r - b.r, a.i - b.i);
}

Cnum mul(Cnum a, Cnum b)
{
     return new Cnum(a.r*b.r - a.i*b.i, a.i*b.r + a.r*b.i);
}

int WIDTH = 500;
int HEIGHT = 500;
boolean changeOnMove = true;    

void plot(Cnum a)
{
    float xPercentage = (a.r - upperLeft.r)/(lowerRight.r - upperLeft.r);
    float yPercentage = (a.i - lowerRight.i)/(upperLeft.i - lowerRight.i);
    int x = round(xPercentage*WIDTH);
    int y = round((1 - yPercentage)*HEIGHT);
    point(x, y);
}

Cnum convert(int x, int y)
{
    float xPercentage = x/float(WIDTH);
    float yPercentage = y/float(HEIGHT);
    return new Cnum((lowerRight.r - upperLeft.r)*xPercentage + upperLeft.r,
		    (upperLeft.i - lowerRight.i)*(1 - yPercentage) + lowerRight.i);
}

Cnum upperLeft, lowerRight;

PFont fontA;

void setup() {
    upperLeft = new Cnum(-2, 2);
    lowerRight = new Cnum(2, -2);
    size(WIDTH, HEIGHT);
    stroke(226);

    fill(226);

  fontA = loadFont("SansSerif.plain-12.vlw");

  // Set the font and its size (in units of pixels)
  textFont(fontA, 12);
  oldMouse = new Cnum(0,0);

}

void keyPressed() {
    if (key == 'q')
	exit();
    if (key == 's')
	save("output.png");
    if (key == ' ') {
	changeOnMove = !(changeOnMove);
	draggedX = 0;
	draggedY = 0;
    }

}

Cnum oldMouse;
int maxIter = 20;
void draw() {
    Cnum mouse;
    background(0);

    if(changeOnMove) {
	mouse = convert(mouseX, mouseY);
	if(mouse.r == oldMouse.r && mouse.i == oldMouse.i) {
	    if(maxIter < 1000)
		maxIter = maxIter + 20;
	    else
		return;
	} else {
	    maxIter = 5;
	    oldMouse = mouse;
	}
    } else {
	mouse = oldMouse;
    }
    for(int q = 0; q < WIDTH; q++)
	for(int j = 0; j < HEIGHT; j++) {
	    Cnum orig = convert(q,j);
	    //Cnum acc = add(mul(orig,orig), mouse) ;
	    Cnum acc = orig ;
	    //Cnum acc = add(orig, mouse);
	    for(int i = 0; i < maxIter; i++) {
		acc = add(mul(mul(acc,acc),acc), mouse) ;
		if(acc.abs() > 2){
		    int strokeColor = 255 - i*5;
		    if (strokeColor < 0 ) strokeColor = 0;
		    stroke(strokeColor);
		    plot(orig);
		    break;
		}
	    }
	}
    fill(0,0,222);
    text("z^2 + cl c=" + mouse.r + " + " + mouse.i + "i", 30, 60);
    if(draggedX != 0 || draggedY != 0) {
	stroke(0,0,222);
	noFill();
	int max = max(mouseX - draggedX, mouseY - draggedY);
	rect(draggedX, draggedY, max, max);
    }

}

int draggedX = 0;
int draggedY = 0;

void mousePressed()
{
    if(!changeOnMove) {
	draggedX = mouseX;
	draggedY = mouseY;
    }
}

void mouseReleased()
{
    if(!changeOnMove && draggedX != 0 && draggedY != 0) {

	int temp;
	if(mouseX < draggedX) {
	    temp = mouseX;
	    mouseX = draggedX;
	    draggedX = temp;
	}
	if(mouseY < draggedY) {
	    temp = mouseY;
	    mouseY = draggedY ;
	    draggedY = temp;
	}
	int max = max (mouseX - draggedX, mouseY - draggedY);

	Cnum lowerRightNew = convert(draggedX + max, draggedY + max);
	Cnum upperLeftNew = convert(draggedX, draggedY);

	upperLeft = upperLeftNew;
	lowerRight = lowerRightNew;
	draggedX = 0;
	draggedY = 0;
    }

}

My Ol’ Fractal Generator

So one of the students was curious about the fractal generator I built last winter, so I figured I ought to finally package it up in a way that was somewhat easy to download.

You download a zip from Google Code:

http://code.google.com/p/fraccontrol/downloads/list

Here’s a sample of the sort of image you can build with it:

Mike’s Ultimate Unix Scavenger Hunt

So working here at GHP, one of the things I get to do is teach seminars. Seminars happen outside of the usual classtime…they tend to be fun special-interest type things. I’m planning on doing a couple but I decided to do the first one on the Unix Command Line. Many of my students have installed Linux. Many even have feelings about which distro is better. But yet most of them have never used the command line. This is very nostalgic for me: ah for the halcyon days of my youth! I made it my business to install every distro yet basically had no clue what one would actually do with a distro once installed. Of course in those days just getting X to work was considered a major achievement.

So anyways I figured they should at least have exposure to some of the cool things you can do with the command line.

I organized it as a “scavenger hunt”. Basically I divided my students into 4 teams and then gave them a list of 30 things to figure out how to do on the command line. The rule was that everyone on the team had to be able to do everything for the team to get credit…when teams called me over I would quiz random team members. This was necessary because we had extremely varied levels of experience…I didn’t want the experienced people just going off and leaving new members to get frustrated.

Basically the whole thing worked like a charm once everybody started working (getting everybody started and on the same page was a bit of a pain). I never cease to be amazed by how much more intense student focus is when they’re working on concrete activities rather than listening to me lecture.

By the end, even students who basically had never worked with Unix before thought the whole thing was pretty cool. The teams basically only got through item 10, but when I asked them who wanted to continue the scavenger hunt next week everybody raised their hands. When I asked them if they wanted to just come back and continue from where we left off or research stuff outside on their own, two of my no-linux-experience girls argued that they just couldn’t wait till the next seminar without playing with it some more.

Funniest thing: a couple of students told me confidentially that they completely understood playing around with the command line for fun, but they weren’t completely convinced that it could actually do anything useful. I found this neat because it seems like normally people feel like command line stuff could be useful, but don’t want to actually go through the bother of learning. That said, I want to provide some persuasive examples next time about how command line stuff can be useful for real.

So unixy friends, here would be two helpful hints I could use from you:

  1. What are some simple and concrete things you can do with the command line that even high school students could understand is awesome
  2. I could use a few more items for my list of 30 command line things. I compromised with the girls: I asked everybody not to research stuff before the seminar so that all the teams could start on the same footing. But I said that I would make an auxiliary list of challenges for people who just couldn’t wait to play with in the meantime.

The Stack, C I/O, Buffer Overflow attacks, Varargs, and Malloc: An Exploding Kitten Approach

So I had a very nice leisurely lecture prepared that talked about the stack, buffer overflow attacks, and C varargs functions. We were going to do a few different activities and maybe even a live coding exercise which I’ve been wanting to try. Then I get an email from my practicum professor saying he wants to cover the stack, C I/O, Buffer overflow attacks, varargs functions, and malloc all in one class session – less than a day before I’m scheduled to speak. That’s over 50 unplanned slides worth of material, jammed into a 90 minute session that already felt a bit disjointed.

I was not feeling the love at that moment.

But what the heck. I figured this would be the sort of real world teaching experience I had been warned about.

Here’s what I did:

  • Eliminated some of my more time-intensive exercises, or replaced them with quicker versions
  • Cut a variety of content that I felt was less important, and distributed it as handouts + an instruction to read the book
  • Created my “exploding kitten” exercise, designed to let me move through the malloc material slight faster. Basically I labeled certain slides with numbered kittens, and as I moved through the students had to record what deadly malloc error each kitten referred to. The idea here was that students would pay extra attention when they saw a kitten, and would know if they missed something so I could go back to it.

All this and I still had to end only 1/3 of the way through malloc.

So looking over my video after the fact, I felt confident that I had completely screwed everything up. But when I tabulated my student feedback, everything was pretty positive. Most common negative feedback: too much material and too fast. I can’t say I disagree.

Here’s the handouts, the powerpoint for the first part, the powerpoint for the second part.

You can watch me here: (part 1) (part 2) if you’re curious.

What awesome CS would you teach the youth of Georgia in 1 class?

So it looks like I’ll be spending 6 weeks of my summer at Georgia’s Governor’s Honors Program (GHP). Students get assigned to a major and minor and basically get 6 weeks of super-intense boarding school. They apply for this, and some don’t make the cut.

I’m looking forward to GHP. I’m looking forward to the chance to teach a completely different group of students. This is kind of class teachers dream about – intelligent, motivated, naive enough to believe your lies. The CS classes will be in the context of a mathematics curriculum which I suspect will present its own challenges. I’m also looking forward to hanging out with a group of professors who would sacrifice 6 weeks of their summer to live on-site and get paid not much. That I think will make for some awesome lunch discussions.

A third perk is the opportunity to teach “seminars”. These are short evening classes that basically can be about anything you can convince a few students to come by and hear about. I’m hoping to use this to try out all the wacky neat-o technologies and techniques I never have an excuse to inflict on the students. I’m already thinking of dusting off my Big O and P/NP lectures. Why? Because I am insane. Maybe also one on Kodu, a super easy game framework by Microsoft that may have little pedagogical purpose but there is something to be said for making a game in 5 minutes using only an xbox controller. And perhaps something with microcontrollers…who knows?

What about you blog-reading people? What fun thing would you just like to inflict on a bunch of high school students? Group theory? Celluar Automata? I am all ears.

For you Seattle-ites: when I’m not tormenting the youth of Georgia, I plan to be in Ben’s place once again living like a drifter. A drifter with a unwavering, ninja-like focus on writing his proposal. But this drifter would not mind grabbing a coffee or drink with any old friends who happen to be out in his direction. I’ll be there from early May to mid-June.

Using the CUI32 StickOS command line in Linux

Even though I really don’t play with my hardware toys much anymore, I keep an eye on the hardware hacker blogs. So when I heard rumors of the CUI32, I admit that I was salivating a little. I told myself it might be a good platform to teach a summer workshop to some high school students. This is like a star-wars fan telling you the $45 Bobba Fett miniature he just bought is “for his kids”.

But the CUI32 platform is pretty hot. Designed for USB. Built in BASIC. Plus there seems to be a built-in bootloader so you don’t need an external programmer.

There is not a ton of documentation for this device. In particular, I had a heck of a time figuring out how to get Linux to communicate with its serial BASIC tty interface. By doing a “ls /dev/tty*” I could see there was a serial device called “/dev/ttyUSB0″. But how to talk to it. I tried minicom but it kept giving me errors. I was wondering if there was some mysterious undocumented setting about party, flow control, or some other madness that I never really understood.

Then I tried putty.

putty -serial /dev/ttyUSB0

Worked like a charm.

Talking about IO and Subroutines

I’m staying home sick today so I’ve had time post a few things that have been in my blogging backlog.

So a few weeks ago I gave a talk about IO and subroutines in the introductory architecture course I was observing. This is the sort of course that CS survivors have nightmares about. The course consists of:

  1. lecture – 90 minutes of agony in which the professor describes breathlessly how exciting interrupt driven IO is and you consider stabbing yourself in the eye with a pencil
  2. lab – a frenzied rush to finish the lab assignment and get out before the TAs get in lecturing mode and you have to hear about interrupt driven IO again
  3. and homework – in which you realize you don’t understand interrupt driven IO after all at 4am in a darkened lab attempting to understand a textbook that seems to have been translated from the original Latvian by babelfish

Now the regular professor is a great speaker who can make even the most mind-freezingly boring topic seem hilarious and interesting. Seriously, this guy went on for 15 minutes on the PDP-8 and while it was going on I completely believed it was exciting and extremely relevant to my life. He also has a grizzled war-vet kinda aura about him that suggests he takes no crap; if he was my professor I would live in mortal fear that if I don’t learn assembly he would one day swoop down upon me like batman and leave my bloodied body hanging from the Klaus rafters as a warning to the other slackers.

But education psychology research has long shown that funny lectures and the occasional beating can only get you so far, especially in this modern age where every laptop provides an infinite supply of funny cats. More to the point, expecting students to remember 8 different details about the way memory mapped IO and subroutines are implemented in assembly is just asking for sadness at exam time unless you’ve built in a little bit of practice and reinforcement.

What was most gratifying about the lecture was the fact that students really seemed to enjoy the activity I had them do. I was pretty concerned that since their regular instructor basically runs a straight-up lecture, they would be resistant to doing anything. Apparently there were a few slackers in the back not working but in general people seemed to do the activity, talk about what sounded like the right stuff after they did the activity, and rate the activity highly on my student feedback forms. Look here if you’re curious on the feedback I got http://bit.ly/aiElj0.

I chose the activities I did (fill-in code blocks and finding bugs in existing code), partly because they were easy, partly because I think students think of coding as a very authentic activity, and partly because I could have specific right answers to hold students accountable and give them feedback. I worry a bit that if I were to teach several consecutive lectures, keeping activities like these fresh could be a problem.

What worked less well was my complex datapath handout. I upped the ante on myself here, because this was something not really covered in the professor’s initial lecture notes. Even the book didn’t really explain this very well: I had to go in and look at a really obtuse and scary state diagram to figure out what was going on. And I have had theory courses, so I assure you that if I say a state diagram is scary, it absolutely is. But I felt understanding the connection between memory mapped io and the hardware was important, and I felt that it would help reinforce the datapath analysis they did in the previous chapter.

So I made a complex diagram. And it took me a very long time. And then in the end, I felt it was confusing. Next time I’m going to put my complex diagram on the fancy overhead box and take some highlighters to it. That will help I think.

My handouts
https://docs.google.com/fileview?id=0Bzy7KJkG2NnQZDBlNzA5YWMtMDg0Ni00NjFmLTg3N2MtOTdkYmY4N2ZmOTNi&hl=en

My slides for IO (annoyingly google docs won’t preview this one)
https://docs.google.com/leaf?id=0Bzy7KJkG2NnQZGM4ZWQ4MjAtNjc5YS00YzI4LWE2MmMtMTE0NzU3MmNhMWNk&hl=en

My slides for subroutines
https://docs.google.com/fileview?id=0Bzy7KJkG2NnQMGU2Y2I5YWMtMGRkOS00NmM3LTgxNmMtMzY4NDhiYTc3MTAx&hl=en

Video of me (part 1 & 2)
http://play.media.gatech.edu/v/public/buzzbox/cetl.gatech.edu/CETL_Practicum/mhewner3-2010-02-23A.mp4
http://play.media.gatech.edu/v/public/buzzbox/cetl.gatech.edu/CETL_Practicum/mhewner3-2010-02-23B.mp4

Using awesome with gnome in Ubuntu 9.10

Awesome is my favorite window manager. It just warms your heart to see it running there in the process list whenever you do a ps –wwaux. And the fact that it is a very nice, flexible tiling window manager is just icing on the proverbial cake.

But it always annoyed me that it didn’t integrate with gnome. I like my drop down application list, complete with wireless control panels and shiny point-and-click applets. Maybe it’s a sign that I’m comfortable enough with my geek-cred that I can admit that. Of course I set all that stuff to autohide so no one looking over my shoulder can can know that I have wimped out.

Now I’ve figured out how to get it working properly. The details are all here: http://awesome.naquadah.org/wiki/Quickly_Setting_up_Awesome_with_Gnome