Scott Hanselman

Learning Opportunity - .NET Terrarium is back!

July 16, 2008 Comment on this post [17] Posted in Back to Basics | Learning .NET
Sponsored By

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)

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.

do something

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?


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

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 16, 2008 23:42
What is a 'huge solid?' ;)

This things rocks. I had forgotten all about it, and can't wait to start playing around with it.
July 16, 2008 23:46
Thanks for the link love Scott. I think an F# or Ruby critter would be way cool. Here's hoping to see popularity rise in the tool and not let this cool way to write games at work die off again. As for the arrow code, strategy pattern my friend, strategy.
July 16, 2008 23:52
Josh - Doing a solid is to do a kindness, a favor, a really nice thing.

Bil - I will expect to see your "Strategic Animal" within the hour, sir!
July 17, 2008 0:27
I've never heard of this before, but it looks really cool. I'll have to look into it.
July 17, 2008 0:43
Damn... I was in College when I first installed this application. That brings back some memory.

I'll install the client and try once more ;)
July 17, 2008 0:57
Sadly It isn't working on Windows Vista :(
July 17, 2008 1:01
Fábio: You're kidding. What doesn't work?
July 17, 2008 1:13
Vista doesn't like the DX7 code.
July 17, 2008 2:00
Dave - You're right. It works on my XP machine, but not on Vista. I believe this is a workaround but it'll just be easier to update the code.
July 17, 2008 4:57
Talked to Scott about this and realized it's the DirectX version (I don't run Vista and didn't realize it doesn't support DX7). I'm just getting the DX9 SDK now and will be doing a Vista update hopefully tonight (depends on how many things the upgrade breaks). Thanks!
July 17, 2008 6:53
Wow! This totally brings me back to like my first PDC ever.
July 17, 2008 7:28
Haha. Terrarium is the shit! Too bad you can't do this stuff with Spore...
July 17, 2008 7:59
Seems like fun, I'll be checking it out later this week.
July 17, 2008 19:06
Awesome! Back in the day all I really got going was a light-phobic plant and a scardy-cat herbivore while learning VB.NET! Time to put some teeth into that sucker! Me thinks C# this time around...
July 18, 2008 20:10
Thanks for the link to the workaround for Vista.
I ran through the steps and I'm up and running now!
July 21, 2008 17:10
> BeginReproduction(null);

I, um . . . so many inappropriate jokes come to mind . . .
July 22, 2008 13:10

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.


Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.