Learning Opportunity - .NET Terrarium is back!
Bil Simser has just done the .NET Community a huge solid. Bil has dug up and re-released Terrarium to CodePlex wtih the intent to update it to use new language features and new usability features like ClickOnce.
If you're newish to the .NET Community (<3-5 years?) you might not have heard of Terrarium. There was a time when it was the tool for getting newbies excited about learning .NET. I showed dozens of high-school and college students how to program using Terrarium. Back at my last company one of our engineers did brown bag lunches on good bug design and ran a Terrarium Server internally.
Terrarium hasn't been even looked at by the Microsoft SDK team in two years, as live happens, you know. Bil hunted them down, did a bunch of paperwork and it's back. You can check out the source or download the release.
You can run it alone, just a world in a box, or you can hook it up to a server and that's where it gets interesting, as your bugs all live in a connected world.
Your animals have Idle (event-based) loops that you can react to, and who amongst us hasn't wanted to write these lines of code at least once?
// Reproduce as often as possible
if (CanReproduce)
BeginReproduction(null);
Now you have the chance.
A great lunchtime project is to get a bunch of the nerds from your company in a room, teach them Terrarium and have a battle!
Personally, I'm a lover, not a fighter, so I run away when attacked.
private void MyAnimal_Attacked(object sender, AttackedEventArgs e)
{
if (e.Attacker.IsAlive)
{
AnimalState TheAttacker = e.Attacker;
BeginDefending(TheAttacker); //defend against the attacker
WriteTrace("Run away to some random point");
int X = OrganismRandom.Next(0, WorldWidth - 1);
int Y = OrganismRandom.Next(0, WorldHeight - 1);
BeginMoving(new MovementVector(new Point(X, Y), 10));
}
}
Go check out the release of Terrarium and download the app, SDK and server. There will be more to come on Bil's Blog, I'm sure. He'll also be running a public Terrarium Server. It's exciting to see this blast from the past. Now I think it's time for me to visit a local High School Computer Science class again some lunchtime...
One of the things I think will be interesting to see, is if folks come up with better patterns for managing state within these animals. Many Terrarium animals end up with Idle loops that look like Arrow Code.
if
if
if
if
do something
endif
endif
endif
endif
This isn't nice to look at, and it would promote bad habits if it was the first kind of code someone new to programming ever saw.
The world has changed since this was released in 2002. The race is on and now I ask:
- Who will write the first aesthetically pleasing (from a code perspective) Terrarium Animal?
- The first F# Terrarium animal?
- The first Ruby (DLR) Terrarium animal?
- Boo? Nemerle? IronPython?
Enjoy!
UPDATE: I've got this running on my XP machine and my XP VMs but because of missing DirectX 6/7 DLLs I can't get it running under Vista. Possible workaround in the comments below. It'll likely be faster to just recompile it. I'll talk to Bil and see what's up.
Related Links
- Five Year Old Tutorial on how to Write An Animal for Terrarium.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Bil - I will expect to see your "Strategic Animal" within the hour, sir!
I'll install the client and try once more ;)
I ran through the steps and I'm up and running now!
I, um . . . so many inappropriate jokes come to mind . . .
Just another idea: It might be interesting to have some custom WF activity library with common behaviours of plants and animals. So one would code the inhabitant's event-driven behaviour by WF state machines.
Martin
Comments are closed.
This things rocks. I had forgotten all about it, and can't wait to start playing around with it.