Scott Hanselman

Learning Opportunity - .NET Terrarium is back!

July 16, '08 Comments [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.

terriarium

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

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, July 16, 2008 7:42:44 PM UTC
What is a 'huge solid?' ;)

This things rocks. I had forgotten all about it, and can't wait to start playing around with it.
Wednesday, July 16, 2008 7:46:33 PM UTC
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.
Wednesday, July 16, 2008 7:52:14 PM UTC
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!
Wednesday, July 16, 2008 8:27:28 PM UTC
I've never heard of this before, but it looks really cool. I'll have to look into it.
Wednesday, July 16, 2008 8:43:53 PM UTC
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 ;)
Wednesday, July 16, 2008 8:57:11 PM UTC
Sadly It isn't working on Windows Vista :(
Wednesday, July 16, 2008 9:01:32 PM UTC
Fábio: You're kidding. What doesn't work?
Wednesday, July 16, 2008 9:13:16 PM UTC
Vista doesn't like the DX7 code.
Wednesday, July 16, 2008 10:00:39 PM UTC
Dave - You're right. It works on my XP machine, but not on Vista. I believe this is a workaround http://www.railforums.co.uk/showthread.php?p=141444 but it'll just be easier to update the code.
Thursday, July 17, 2008 12:57:54 AM UTC
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!
Thursday, July 17, 2008 2:53:06 AM UTC
Wow! This totally brings me back to like my first PDC ever.
Thursday, July 17, 2008 3:28:01 AM UTC
Haha. Terrarium is the shit! Too bad you can't do this stuff with Spore...
Thursday, July 17, 2008 3:59:57 AM UTC
Seems like fun, I'll be checking it out later this week.
Thursday, July 17, 2008 3:06:25 PM UTC
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...
Friday, July 18, 2008 4:10:41 PM UTC
Thanks for the link to the workaround for Vista.
I ran through the steps and I'm up and running now!
Monday, July 21, 2008 1:10:34 PM UTC
> BeginReproduction(null);

I, um . . . so many inappropriate jokes come to mind . . .
Tuesday, July 22, 2008 9:10:24 AM UTC
Hi,

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.

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