In the first episode of Greenfoot Adventures, we left our colleagues lost in San Francisco, trying to find the ultimate Greenfoot Scenario. They rode all over this hilly city, and found nothing more than a big bridge. Silly Greenfooters! There are no Golden Gate Bridges in Greenfoot Scenarios!

So, I present to you, the second edition of Greenfoot Adventures, where the team is presented with a 2007 Duke’s Choice Award at JavaOne, yet are still unsuccessful in finding the Ultimate Scenario. In part, this is because no scenarios have (yet) been submitted to the MyGame site, and as a result, noone is in danger of winning the competition.

So, I present to you Greenfoot Adventures: The Search Continues. In case you missed the first edition, they’re all linked in here.

  1. Greenfoot Adventures Day Zero: In Search of the Perfect Scenario (17MB PDF)
  2. Greenfoot Adventures Day One: The Search Continues (13MB PDF)

Page 1-1

2007_awards

Greenfoot was selected as one of the 2007 Duke’s Choice award winners, which was presented on May 8th at JavaOne. This is a very, very big deal. I’ve already seen some companies doing big, nifty press releases; those press releases are boring compared to what I do, so you should be glad you’re reading this instead of those press releases.

What is Greenfoot, and how did it win this award? Ah! Well, Greenfoot is a very exciting microworld where you can program all kinds of exciting environments in Java, and watch your creations interact in ways that you (possibly) never expected. You can check out the Greenfoot site for tutorials, examples, screenshots and the like.

So, in the next post, I’ll continue my series of press releases surrounding this very exciting event: Greenfoot Adventures! That’s right, in celebration of this award, I’ve developed an entire web comic chronicling the adventures of Poul, Michael, Cecilia, Ian, and Bruce in San Francisco, as they search for the ultimate Greenfoot Scenario!

Yeah, it’s definitely that cool.

For posterior’s sake, I’ve kept the old version of my first edition of the web comic. I want to be clear—I really don’t think my friends should go play in the street. Playing in the street is dangerous. When I was younger, I played Frogger, and I know what happens when you run around on a busy highway. And as Michael, Poul, Cecilia, and Bruce are all traveling as internationals, crossing the street can be very dangerous. Had they been caught BlueJ-walking, or looked the wrong way while crossing the street… well, lets just say that Davin and I would have rushed over to San Francisco to make sure they were OK. Because we care. About being in San Francisco. In spring.

This new edition of the web comic is great awesome. I mean, I now have a story line—an arc, if you will—that I can use to motivate all of my web comics. Obviously, the group must be… on a quest for the perfect scenario! You might wonder how I missed such an obvious play last night while watching the snooker: it baffles me as well.

So, I’ll leave the previous comic for you to enjoy, but this new one is really supersuper.

Page 1-3

Grab it here.

My MSP430-4619LCD development board arrived today from Spark Fun. Indeed, I got the last one they had in stock. Ha!

Top:

MSP430-4619LCD-02-L

Bottom:

MSP430-4619LCD-01-L

This board has a Texas Instruments MSP430 (bottom), 128×128 color LCD (top), joystick (top), two buttons (top), 3-axis accelerometer (top), and SD card slot (bottom) for storage. This is a very cool little development platform, and you can bet that I’ll be running the Transterpreter on it shortly.

Awesome.

Poul was kind enough (*cough*) to send some pictures of their first day in San Francisco. Now, JavaOne hasn’t started just yet, so they’re apparently having a rough time of it around the Bay area.

Poul only had this to report:

Don’t worry too much that you are not here. San Francisco really sucks -
Canterbury is a lot more interesting. Nothing to do here and it is
almost freezing outside. :-P

Poul lies like a sick dog.

Given that he had little else to say, I was obligated to figure out what was going on from the pictures he sent and fill in the gaps given my knowledge of Poul, Cecilia, Michael, and Bruce. Given that I know them all as well as I know my towel, I’ve put together (just for you!) the first edition of the most amazing and excellent web comic… Greenfoot Adventures!

Page 1-2

You can download the first edition (PDF, 17MB) of this limited run, truly remarkable web comic, and then proceed to Share and Enjoy(tm). Fortunately, it’s only 11 pages of Vogon-quality comic!

It’s interesting that Bill Clementson caught my backup post recently. For a while, I had a script that ran JetS3t as a backup. Now, I need to use that to recover my data from Amazon’s S3 service. I mostly used it to backup some documents and my photo archive. Fortunately, my photos are backed up, but I lost all of my music. C’est la vie; it can be restored.

However, I’ve taken a new tack on backups, actually. Like Bill, I’ve decided I don’t mind a little bit of a proprietary solution if it makes my life easy. I’ve signed up for mozy.com, which at $5/month is a steal. It backs up as much of my hard drive as I want, encrypts it on the way, and I don’t have to write any funny scripts or remember to do anything. Perhaps I’ll swap over to something S3 based in the future, but for now, it’s too easy at the right price.

In the meantime, I’ll use JungleDisk for archival—I keep my S3 space mounted as a dumping ground for things I want to keep for a long time. Or, at least, things that I want to last past my next HD crash or move from one university to the next. Through the combination of JungleDisk and Mozy, I’m pretty much good to go.

I think.

Today, I’ve spent my day watching the X-files (season 6) and copying data off of old CDs and DVDs. I’ve got data that goes back to 1997, and I figure it’s a good time to round up some things and get them backed up somewhere else. Big moves tend to make for good opportunities to back things up.

More on that later.

We ran into something interesting the other day on the LEGO Mindstorms. In particular, something to do with time.

You see, the LEGO is a 16-bit machine. This means the largest number it can represent is 2^16 – 1, or 65535. This is OK in most cases, but I want to note that the LEGO’s clock runs at millisecond speed. That means that it ticks over once per millisecond. The number of milliseconds we can count before the clock rolls over is… 65,535.

If there are 1000 milliseconds in a second, that means that we can only count up to 65 seconds before the world ends. Now, this is fine for James Bond movies (where the hero always has one minute to accomplish his death-defying task), but we kinda want to be able to measure longer amounts of time than that.

In occam-pi, we can do this in some very cool ways. So, consider this a brief introduction to timers in occam-pi, and more specifically, how we can neatly create timers that ‘tick’ at arbitrary intervals without too much effort. I’ll continue this later in another post that explores how I build up to having timers that let me measure hours, days, weeks, and even months on the LEGO Mindstorms. For the moment, I’ll start with some basics about timers.

To start, occam-pi has a notion of a TIMER built into the language. This is kinda cool. If I wanted to write a process that would delay for some number of milliseconds, it would look like this:

PROC delay (VAL INT timeout)
  TIMER t:
  INT the.time:
  SEQ
    t ? the.time
    t ? AFTER timeout
:

The process takes one argument, which is a timeout value given in milliseconds. The timeout value has a type, which is VAL INT. This means that it is an integer, and furthermore, we cannot change it—any attempt to modify this value will result in a compile-time error. In other words, we’re saying it is a constant within this PROC.

We then declare two local variables: one of type TIMER and one of time INT. In sequence, we then read the current time into the variable ‘the.time’, and then use a funny bit of syntax to do our delay:

t ? AFTER timeout

This is some ugly stuff—something I wish they had done differently in the language. However, occam is over 20 years old, so we’ll cut it some slack. This syntax says “delay until timeout milliseconds have passed.”

And that’s it. What’s nice about this PROC is that it does not block other processes from doing their stuff. So, it effectively says “sleep, but let other people run around and do things.” Very cool.

Now, we can’t use this process to delay for more than 60 seconds or so, because the LEGO Mindstorms is limited by a maximum of roughly 65K milliseconds. Since I want to be able to do nifty things that involve timing out for more than 60 seconds, I want to start by writing a ‘ticker’ process that will generate clock ticks that I can listen for at intervals other than milliseconds.

PROC tick.generator (VAL INT delay, CHAN BOOL tick!)
  TIMER t:
  INT timeout:
  SEQ
    t ? timeout
    WHILE TRUE
      SEQ
        timeout := timeout PLUS delay
        t ? AFTER timeout
        tick ! TRUE
:

This is only slightly bigger than the previous PROC. The tick.generator has two arguments—a constant (VAL INT), and a channel that carries booleans (CHAN BOOL). The channel is an output channel because it has been decorated with a !. (The compiler can figure this out for itself, but good style dictates that we put the ! on the channel end in the PROC definition.)

Again, I declare the local variables t and timeout, read the current time, and then drop into an infinite loop. This loop increments the timeout value, delays, and then outputs a signal on the boolean channel. Now, I can put this and a few other things together to create a complete program. This will execute just fine on your desktop, so if you paste it into your JEdit window, save it as “ticker.occ”, compile, and run, you can see what it does. (Note that I’ve defined constants for SECONDS and MILLIS; on the LEGO, you would redefine MILLIS to be 1.)

VAL INT MILLIS IS 1000:
VAL INT SECONDS IS 1000 * MILLIS:

PROC delay (VAL INT timeout)
  TIMER t:
  INT the.time:
  SEQ
    t ? the.time
    t ? AFTER timeout
:

PROC tick.generator (VAL INT delay, CHAN BOOL tick!)
  TIMER t:
  INT timeout:
  SEQ
    t ? timeout
    WHILE TRUE
      SEQ
        timeout := timeout PLUS delay
        t ? AFTER timeout
        tick ! TRUE
:

PROC tick.seconds (CHAN BOOL tick!)
  tick.generator(1 * SECONDS, tick!)
:

VAL BYTE flush IS 255:
PROC show.seconds.tick(CHAN BYTE kyb, scr, err)
  CHAN BOOL ticker:
  PAR
    tick.seconds(ticker!)
    WHILE TRUE
      SEQ
        BOOL tmp:
        ticker ? tmp
        scr ! ‘x’
        scr ! flush
:

The last process, ’show.seconds.tick’, demonstrates how we don’t always have to name our processes to run them in parallel. First, I declare a channel to carry boolean values (remember, channels are like wires—channels carry information from one process to another.) Then, in parallel, I want to run the process ‘tick.seconds’ and an infinite loop that I’ve written. The process ‘tick.seconds’ gets one end of the channel ‘ticker’—in particular, it gets the end of the channel that will be written to.

In the infinite loop, I do a few things in sequence. First, I declare a temporary variable that is only valid for one line of code. That is, it exists just long enough to read from the ticker channel into the variable ‘tmp’. This is because I don’t actually care about keeping that value, but I have to read from the channel into something. After reading from the channel, I output an ‘x’ to the screen, and then I flush the screen, so that the output is actually shown.

Remember that occam-pi channels are blocking channels. That means that my infinite loop will stop every time it hits the line ‘ticker ? tmp’. It will wait until the process ‘tick.seconds’ has written a value, and then the loop can continue. Also, it is important to remember that every time you see a channel read (eg. ‘ch ? var’) or a channel write (eg. ‘ch ! var’), the Transterpreter deschedules the currently executing process, and goes and runs something else. This way, everyone gets a turn to execute. This is why the delay process I introduced earlier does not block everything running on the system, and why we can write infinite loops as casually as I have here… because each one contains a channel communication.

In my next post, I’ll follow up with how to extend this into timers that can last for days or even weeks on something as small as the LEGO Mindstorms. Also, I still need to follow up on our subsumption code for the Surveyor—but that will come, perhaps, after this timer exploration. In fact, this came up because we were trying to run our code from the Surveyor on the LEGO, and we discovered that having a 32-bit timer (like on the Surveyor SRV-1) is very handy, while having a 16-bit timer (like on the LEGO Mindstorms RCX) is a bit annoying… where “annoying” means “Hey! Our code doesn’t work!”

Yes, that’s right—the BlueJ/Greenfoot team is off to JavaOne, and who do they leave behind? Who I ask! That’s right. They leave their blogger and star developer, Davin. (Davin, being in Australia, doesn’t actually count, but I feel obligated to mention him here anyway.) Now, what they apparently don’t know is that the blog is mightier than the sword, and given that Davin maintains greenfoot.org, and I write the blog, they’ve left the two most dangerous people in the world behind—bitter, lonely, and ready to do something about it.

While Bruce, Ceclia, Ian, Michael, and Poul are off having fun in San Francisco, Davin and I (get this) will be reporting to you on JavaOne. I want you to pay attention here, because this is important: the two guys left in Canterbury, England, and MmumblemumbleSumbuleumble, Australia will be reporting to you on the exciting things taking place at JavaOne. Honest. Really.

In fact, look at this cheeky email Michael sent the night before they all took off for beautiful San Francisco:

Matt,

Would you like to write a running commentary of the JavaOne
competition (a short post or two a day) on walkabout while that’s
going on? If you did, we would advertise it at the conference…

(You would mainly look at the submissions on mygame, but if anything
interesting happens in the “Real World”, we might let you know…)

mik

If I may borrow from Marvin: “Here I am, the brain the size of a planet, and they ask me to blog about JavaOne.”

So watch this space. Davin and I have some things to say!

I thought I’d run a post that is pulled straight from the greenfoot-discuss mailing list. I thought it was a good user story, as it illustrates some of how people “out there” are using Greenfoot, as well as being a fun read. At least, as someone who has taught Java using the Objects First textbook and used Greenfoot in the classroom, I certainly enjoyed the read.

This note comes in from Barry Brown at Sierra College:

I’ve been running a CS11 class this semester using BlueJ. I saw Greenfoot demoed at SIGCSE2 and participated in the Greeps competition.

Once the students completed chapter 4, I thought it would be a perfect opportunity to have a bit of fun and give them lots of practice writing Java. For two weeks, my students tackled the Greeps competition.

A bit of background: my students range in age from 17-ish up to the 40s. I have three high school students among traditional and returning college students. The students’ experience with Java is mixed; some were beginners and others had been exposed to Java before.

I introduced the competition on a Monday. They were shown the Greep class and the inherited methods from Creature. I started them out with a few hints, such as the obvious improvement of having the Greeps turn away from the water or the edge.

On Wednesday (two days later) we had the first round of competition. Of course, I ran the Greep classes on all ten maps. The top five finishers scored 52, 56, 61, 68, and 244. Interestingly, the 244 score was earned by a pair of the high schoolers and falls only 1 point short of the overall winner at SIGCSE.

Next Monday, we ran the Greeps again. This time the top five scores were 150, 174, 195, 215, and 254. The top two scores were earned by the same pair of students who were the top scorers in the first round. (They decided to split up and run their Greeps separately. Later, I would find it was a carefully calculated strategy to win.) Nearly all of the students had figured out how to get the Greeps to stop at the tomato piles and most had some kind of algorithm to steer them around the water.

Finals were on the following Wednesday. As with the SIGCSE competition, we did best-of-three for the finalists. The top five scores were 198, 206, 230, 236, and 281 with the top two scores being earned by the same two high school students.

Feedback from the students were overwhelmingly positive. Memorable quotations:

This was a lot of fun.

Much more fun than BlueJ.

I spent more time on Greeps than my other classes.

All students got a lot of practice invoking methods, reading documentation, writing loops and conditionals, and learning to make use of limited resources. In fact, by the time we got to Chapter 8, the subject matter of inheritance was easy and obvious. They had seen it all before in Greeps!

Kudos go to the Greenfoot team. Playing with Greeps was a fun break from the BlueJ exercises. I’m not sure if I would use Greenfoot exclusively next time, but I’m really leaning toward mixing BlueJ and Greenfoot.

What I like about this post is not just that it is a positive reflection of the use of Greenfoot in the classroom, but that Barry has provided a glimpse of his thoughts on how he would use it in the classroom in the future. The notion of mixing Greenfoot in with exercises from the Objects First textbook is certainly a good one, and might provide some good direction for a set of companion modules that instructors might use throughout the text for enrichment.

Also, what I think is even cooler was the constructivist learning that took place through the use of the Greeps competition. In particular, the students were not phased by the notion of inheritance when they saw it in the text because they had leveraged it throughout the Greeps competition. The purpose of the competition was to score points; however, the students were willing to tackle new learning in their attempt to score more points in the Greeps competition. This kind of self-driven, authentic learning is (in my opinion) the most powerful kind of learning an instructor can encourage in their classrooms. It usually requires giving students ill-defined challenges, and being willing to relinquish some control over how things will progress… but the rewards in terms of learning outcomes can be significant.

So, very cool stuff. That’s it for today, but in my next post, I really want to dive into a new feature in Greenfoot: the ability to export projects for sharing on the web! This is at the heart of the MyGame site, and will factor heavily into what I’m working on over the next few months. I think it is awesome, and before I’m done, I expect you will too.


Footnotes

1 CS1 is shorthand in the USA for a first course in computer science. It often implies a programming-intensive course, but not always. (back)

2 SIGCSE is the ACM Special Interest Group in Computer Science Education. When used in this way, “SIGCSE” implies the annual conference held in the USA each spring. Roughly 1400 computer science educators from all over the world, typically working with high-school and university-level students, attend. (back)

I’m pleased to say that for the last few months that I’m in Canterbury, I’ll be working more closely with the Greenfoot team on some very cool stuffs.

GameLogo

Today, Michael announced the opening of the JavaOne competition. This competition will leverage MyGame, a site put together by James Gosling to support the team’s presentation of Greenfoot at JavaOne. Programmers will be challenged to develop the most compelling entry (based on community voting). I’ll be posting more about it as the contest evolves—just know that your entries could win you a SunSpot (a very cool Java-powered, embedded device), or your participation through voting and reviewing could earn you a Greenfoot T-shirt! (I have two. I’m not sure why, but I have two. They’re awesome. If you don’t have one… well, you’re still kinda cool.)

While it wasn’t possible for them to bring their blogger to JavaOne (humph!), I will be helping develop MyGame into a full-peer application in the BlueJ/Greenfoot pantheon. Our goal is that it will become a long-running service to the Greenfoot community, providing a showcase and rallying point for people writing scenarios in this very cool object world. Along with this, I expect I’ll be keeping up on the Greenfoot blog a bit more (as it will be Justifiable as Work), and will be taking some more time to demonstrate the most recent (and very cool) features included in Greenfoot.

So, watch this space!