Multiplayer Game Programming
Tuesday, June 21
Diablo Valley College is having severe network problems, so the kids' computers are unusable today.
Plan
Dave shows his Roomba, the robotic vacuum cleaner
Is it a computer?
Discussion of programming
What decisions? State? Loops?
Animusic, play tracks from DVD
How was this done? What programming is involved
Kids introduce selves, talk about programming experience
Program demos
Teaching assistants
Chris
Ian
Mine (source in DBSchools project on sourceforge.net)
Math quiz multiplayer game
others (see Java Run dialog)
Run python client to connect to Java server
Introduction to TCP/IP client/server concepts
Reflection
This is a small class. Lots of individual attention. Two students to each teacher/TA. The kids learned:
Multiplayer games often consist of a server and one or more clients.
To connect to a server the client must know the server's name or IP address, and the port the service is on.
A single computer may offer several services: Web, mail, and various games, for example.
I ran a simple server, written in Java, which accepted connections on
port 8000. I showed how we can use the "netstat -a" command to confirm
that the server is indeed listening on that port. We ran a short Python
program which connected to the server and interacted with it. The
server is a simple text-based "game" (or the beginning of one,
perhaps). The server says "Welcome" and then waits for a command. If a
command it recognizes is issued, it sends a certain response.
Then I showed how one can use the telnet command (telnet localhost
8000) to connect to the server, without using a custom-written client.
We had a review where everybody told something they learned in the class.
We watched a Roomba robotic vacuum cleaner and talked about how it
works--what kind of programming it must contain. We wonder what kind of
awareness it has, and talked about it as if it had human
characteristics. I told everybody that that's called
"anthropomorphization," and cautioned them, "Don't anthropomorphize
computers. They hate it when you do that!" (One of my favorite jokes.)
Half of them laughed--hard. I told the rest to keep thinking about it.
Wednesday, June 22
Plan
All classes: review, student introductions
Python: Continue Lesson One (see "Lesson One" announcement)
Squeak: Tutorial 3 from squeakland.org: make a car that drives by
itself on a track. Then apply the new skills to make something of your
own invention. Here are some ideas:
A skier going down a slope
A plane that flies into a cloud, then does a 180-degree turn
A robotic vacuum cleaner moving around a room with obstacles
Two people that avoid walking into each other
Multiplayer game programming: Demo of the "math quiz game" (see
sourceforge dbschools). Break into three groups. Students learn to use
Eclipse to create Java programs. Introduction to Java. Creating a
ServerSocket. Connecting to it with telnet or a client in Java or
Python.
Questions for students:
What is Eclipse?
What is a class?
What is a ServerSocket?
What does it mean to "connect"?
Reflection
We had a review where taking turns, each student chose another student
and asked him a question about a key topic from yesterday. It was very
effective.
We split into groups of two and learned how to use Eclipse
(eclipse.org) to create a Java project and Java class file. The kids
liked the individual attention, and seemed to get the concepts. We
didn't have a quiz, so we'll see tomorrow in the review how much they
retained. The network is still down here so we can't use the QuickQuiz
program (dbschools.com) for real time assessments.
We considered how different it is creating a "Hello World" program
in Java from doing it in Python. In Python, of course, it's something
like:
print 'Hello World'
and in Java, it's more like:
public static void main(String[] args) {
System.out.println("Hello World");
}
}
There are quite a few more concepts to cover in Java.
I told a little of the history of free (free as in freedom)
software and open-source software, and I said that all of my program
examples are in the DBSchools project on sourceforge.net.
Thursday, June 23
Plan
Croquet demo
Continue: Introduction to Java. Creating a ServerSocket. Connecting to it with telnet or a client in Java or Python.
Reflection
TA Chris Gibson gave an very interesting ten-minute demo of Croquet
(www.opencroquet.org). The kids were fascinated by it. We will think of
how we might be able to use it in the classes.
We continued with small group instruction in Java, using the ServerSocket class. Trying to explain a line like
ServerSocket serverSocket = new ServerSocket(1000)
is quite a challenge. I'm leaning towards using Python more than Java.
Tuesday, June 28
Plan
Continue learning Java and ServerSocket. Learn Socket and connect to the ServerSocket with Socket.
Reflection
We had a "checkpoint," where I asked everyone to create a Java class with a ServerSocket that accepts a connection, in ten minutes, using their notes or a set of Web-based resources. None of the six succeeded, but one came very close. I hope everyone learned the value of notetaking. I again thought of doing less with Java and more with Python.
Wednesday, June 29
Plan
Walkthrough of the math quiz game. Getting source code from sourceforge.
Reflection
We learned about ping and traceroute, and finding out what our IP
address is. We pinged several machines around the globe and compared
the response times. With traceroute we talked about how there are
usually several routers in between the endpoints of a connection.
I ran the math quiz game, and the kids connected to it with telnet, and we played for a few minutes.
We learned how to navigate through the DBSchools sourceforge project
CVS tree, and we looked at the code for the binary clock and the math
quiz game.
I wore my shirt: "There are only 10 types of people in the world: Those
who understand binary and those who don't" and that sparked a
conversation about the binary number system. We played with the Binary
LED Decoding Game
(http://davebsoft.com/Computer_Training_for_Kids/Class_Materials/Runnable_Applications/index.html)
and kids got the hang of that.
Thursday, June 30
Plan
Getting started with Pygame and networking in Python
Reflection
Today we left Java for awhile and introduced Pygame, similarly to the
Python class. One student was able to create a second graphic in the
bouncing ball program, with very little help. I announced that we will
create a multiplayer game using Pygame and network programming.
Tuesday, July 5
Plan
Introduction to Squeak. TCP client/server programming in Squeak.
Reflection
We had a good introduction to Squeak. I'm getting ideas from the Squeak community on how best to use Squeak for this class.
Wednesday, July 6
Plan
Squeak's collaborative features: dropping a Morph on another student's world.
Discussion of exchanging data between clients and server in Squeak.
s_Socket newTCP
s listenOn: 5000
s2_Socket newTCP
s2 connectTo: (NetNameResolver addressFromString: '127.0.0.1') port: 5000
s sendData: 'abc'
s2 receiveData
Reflection
Playing with Sockets went fairly well, but wasn't nearly as exciting as Squeak's collaborative features.
Thursday, July 7
Plan
QuickQuiz:
telnet
ping
traceroute (tracerte)
netstat
ipconfig
ServerSocket
what info to connect to a server
number 5 in binary
Sourceforge
open source
Richard Stallman
Lesson: Walkthrough of the math quiz game
Further play/experimentation with Squeak's collaborative features
Reflection
The kids did pretty well on the quiz. One boy was the clear winner.
This boy took notes every day. Most of the rest did very well. I think
we were successful in teaching TCP client/server concepts and in
building a foundation for learning to create multiplayer games. I was
disappointed that we didn't actually have a multiplayer game at the
end. This is partly due to my changing "preferred" languages twice, and
perhaps because the class is too ambitious for just 9 hours with kids
of this age. What will we change for the second session, starting next
week?