Monday, January 08, 2007

Online simulation games and learning

I really like the concept of using games to learn something.

Games are fun, and can take a subject that a person may find boring, and put a fun slant on it.

My kids are interested in this MMORPG game called Dofus right now. We did the 7 day free trial and then I bought a month of play time for them. I think they like to concept it shares with Pokemon and other fantasy games: characters that can "evolve" in some way. Gain knowledge and skill, new powers, etc.

I remember when I was a kid, this character development was a powerful thing for me. I used to have loads of fun just talking through being different characters with my friends.

Now, the Dofus game does not have a direct educational element to it. But there are lots of lessons in there.

  • How to work together as a group for a common goal
  • Evaluating risk -- knowing when not to battle with another character because it is too powerful
  • Working toward a long-term goal -- they see other characters further along and see that they can get there too if they work at it

The tough nut to crack is how to make an intentionally educational game as appealing as the entertainment games are for kids.

The first 6 months of the year, I worked on a project funded by a grant from the National Science Foundation. We created a prototype of an online, multiplayer game for kids dealing with Global Warming. We called it C02FX

CO2FX is a web based multi-user educational game which explores the relationship of global warming to economic, political and science policy decisions. The game is driven by a systems dynamics model and is presented in a user friendly interface intended for the high school user.

I think in the 6 month time period we had, we did a pretty good job on this game. We used a STELLA model to drive the simulation, and Flash to build the user interface.

Dofus uses Flash as the interface as well, and it is very slick. It is the best looking Flash application I have ever seen. Something to work towards if the team can take C02FX on further.

We are still looking for funding for the next phase of development. We may be awarded a phase 2 grant from NSF, but we need to demonstrate the ability for the application or platform to be productized.

Anyone have any good examples of this?

High Performance Systems used to have a relationship with Harvard Business School Publishing and created a few Learning Environments that were used in course study and sold as stand alone applications. These Learning Environments were CD ROM based and had ithink models driving them.

HPS also created other Learning Environments, that I think were ahead of their time. Maybe now the world is ready for this sort of thing...

Reflection in .NET

A couple of days ago I used Reflection for the first time in a .NET project. Very cool.

I have always known the System.Reflection namespace was there and a very high level understanding of what it does, but never actually used it or seemed to have a need to.

Well, on Wednesday I had a need for it. I was trying to map bits of XML structure into strongly-typed .NET classes. So I'd have something like this:


...that I wanted to turn into a .NET class.

So my dilemma was this: I had to write virtually the same piece of code over and over for each node in the XML to map it to the appropriate property in the class I was building and cast the value from the XML to the appropriate type.

So I thought, "...what I need is a function where I can pass in the property name, the XML node name and data type and have it populate the correct property with the correct type". And then I said it out loud to Ryan. And he said, " Java you'd use Reflection." "Ahhh..." I said.

With Reflection you can query an object for meta data at run-time.

In .NET everything that inherits from System.Object, gets a method called getType(). This returns a "System.Type" type. Then on that type object, you can ask for information about a property of the object by passing a string of the property name. Then you can tell the reflected property information to set a value for that property by passing an object for the value and a reference to object instance that contains the property.

Here is a snippet of the code:

Type theType = obj.GetType();
PropertyInfo propInfo = theType.GetProperty(propertyName);
//To hold the value of the property we wish to set
object propValue = new Object();
//The type of the property we wish to set
Type propType = propInfo.PropertyType;
//The string value from the XML, which we will convert to the appropraite type
//for the property we wish to set
string xmlValue = xmlMarkupRoot[childNodeName].InnerText;
//Here we'll need to test for the basic types
if(propType == (Type.GetType("System.Double")))
propValue = Convert.ToDouble(xmlValue);
else if (propType == (Type.GetType("System.String")))
propValue = xmlValue;
else if (propType == (Type.GetType("System.Int16")))
propValue = Convert.ToInt16(xmlValue);
else if (propType == (Type.GetType("System.Int32")))
propValue = Convert.ToInt32(xmlValue);
else if (propType == (Type.GetType("System.Single")))
propValue = Convert.ToSingle(xmlValue);
else if (propType == (Type.GetType("System.Boolean")))
propValue = Convert.ToBoolean(xmlValue);
propInfo.SetValue(obj, propValue, null);
Pretty sweet.

ASP.NET -- Cleaning up objects that live in the Session when the session ends

I spent a while coming up with this solution, so here it is for all the world to enjoy.

So you have some object that needs to be persisted between pages, so you pop it into the Session. This object may need to have some clean up done to it when it's done being used to free up resources -- like say calling the Dispose() method or similar clean up to take care of unmanaged resources.

No problem, just wire some code to the old Session_End event in Global.asax and call Dispose(). Well, that is wrong as you probably know. When Session_End fires, you can no longer reference the Session, which means you can get a reference to your object.

So here is what I did -- I put my object in the Cache instead. The Cache is Application wide, so I key the object by the users SessionID. When I insert the object in the Cache, I set a sliding expiration that is equal to the Session timeout.

string sessionKey = HttpContext.Current.Session.SessionID;
TimeSpan sessionTimeout = TimeSpan.FromMinutes(HttpContext.Current.Session.Timeout)
CacheItemRemovedCallback onRemove = new CacheItemRemovedCallback(someClass.SomeStaticMethod);

HttpContext.Current.Cache.Insert(sessionKey, /* key */
mySessionObject, /* the object */
null, /* dependency - file, folder or other keys */
Cache.NoAbsoluteExpiration, /* Absolute Expiration */
sessionTimeout, /* Sliding expiration */
CacheItemPriority.NotRemovable, /* Priority */
onRemove /* Callback function when removed */);

The key here is the sliding expiration. The timer counts down and is reset every time the object is accessed. So when the user closes the browser or leaves the site, the timer will eventually count down and expire the object from the Cache. That's when the callback function is fired. The callback function passes the key, the object and a reason why it expired to the handler. So you can grab the object at that point and call Dispose() or what have you to do the clean up you need to do.

public static void onRemoveObjectFromCache(string key, object value, CacheItemRemovedReason r)
MyCoolObject obj (MyCoolObject) value;

Monday, September 12, 2005

A new page

Well, Friday September 9th was my last day at my full time job with Nexus Energy Software. I worked there for just over 2 years. The 3 guys I worked with in the Lebanon NH office were every cool to work with. I made some good friends for years to come.

So, now I'm on my own. A full-time independent software developer. For the coming months I'll be spending half of my week doing some long term work for my former employer, isee systems. The other half of the week I'll be working on short term projects and doing other business building activities.

I've got the health insurance for the family rolling along, and for the first time in a very long time, Karrie will have health insurance too!

So, wish me luck. I think this will be a grand adventure. I'll be doing the work I love, and I'll have more time with the kids to do stuff like this:

Wednesday, June 22, 2005

New projects

I have posted part 1 of the ploy-tape electric fence and PVC chicken tractor projects over to the Adventures in Pastured Meat blog.

Check it out if you're interested in farming and DYI projects.

Saturday, June 18, 2005

New Kitten

Mesa wanted a new kitten and our neighbor had some, so we now have a new addition to the Merritt Family Petdome: Hershey

Wednesday, June 15, 2005

Adventures in Raising Pastured Meat

I have started a new blog on raising pastured meat since we are about to embark on a bunch of projects to ramp up production this year.

Check it out:

Also, I put this blog on TypePad -- which I'm really liking a lot so far :)

Monday, May 23, 2005

It's been a while...

Hi all.

I've been super busy as of late, so not much posting here.

Quick recap of what's been going on:
  • I got a mountain bike, and have been riding trails to get my sorry-ass out-of-shape office worker body into shape
  • I've been playing Volleyball on Thursdays also to keep in shape and get a regular brake in from all the work I have been doing. I suck, but am getting better -- and it is fun.
  • I have been doing a ton of extra work, (outside of office hours), on a National Science Foundation grant-funded project. It's an online multiplayer simulation dealing with global warming. It is targeted for 8th - 10th grade students. The simulation runs in Flash in a web browser. I have designed the architecture and have been doing some code-slinging to get everything in place for the interface designer and advisors on the team. We'll be doing the first user-test on Thursday.
  • We are gearing up the mini-farm: meat chicks are almost 4 weeks old; I'm building a feather plucking machine; we'll be getting some lambs and pigs soon and the farmers market starts this weekend.
  • We've been looking at buying some land and building a house. How knows what will come of that...
  • The transmission in the Van dies and we had to replace it. Bummer. 2K later and we have a new transmission with a 50K warranty.
  • Mesa has been taking an archery class and is doing really well.
  • Terran is turning out to be quite the little biker.
  • Aanan is, as usual, off in her own world having a grand time.

That's all I can think of for now...

Sunday, April 24, 2005

Trip to Maine

I took the kids to Maine last weekend for 4 days, and we spent one of those days biking the carriage trails in Acadia National Park. It was a great day for it, and we did about 10 miles. Here are some pics.

Tuesday, April 05, 2005

Goats and ITP Update

Took Terran in for a blood test on Monday and his count was 773,000! He's weaningoff the prednisone this week and is done going to the hospital. We can declare victory against ITP!

The doctor said don't bother bringing him in any more, just watch for nosebleeds and easy brusing and other signs of low platelet count.

In other news, we now have 3 female goats:

We will raise them up and then breed them and use them for milk purposes. Perhaps we'll even make some goat cheese. The extra milk will go to the pigs we plan on raising.

See some great goat photos here on Flickr.

Tuesday, March 29, 2005

Terran Update

An update on Terran's ITP:

I took Terran in for a blood test and follow up appointment with the doctor yesterday and his platelet count was 503,000 !!!!

This is great news and means he's responding well to the prednisone treatment. He'll stay on it for a while longer on a reduced amount, but the best news was that he can act like a normal kid again and jump around and play without worry of his blood not being able to clot!

Thank you all for the kind words and support.

Wednesday, March 23, 2005


So, Terran has been diagnosed with ITP, (Immune Thrombocytopenic Purpura).

ITP is a bleeding disorder caused when the body?s defense (immune) system mounts an attack and destroys healthy blood platelets thinking they are disease-causing agents.
Immune - the immune system is involved
Thrombocytopenic ? the blood does not?t have enough platelets
Purpura ? bleeding into the skin or bruising.

(EDIT: The "I" also can stand for idiopathic, which means 'of unknown origin'.)
It means he can't stop bleeding. He was diagnosed on Monday.

This past weekend, Terran, Mesa and I went to Maine to visit my Mom and family. On Sunday he awoke with a bloody nose. I could not get it to stop bleeding before we left around noon. I thought it was because he kept picking at it.

On the way home we had a great time and stopped at LLBean, and then had lunch at Gritty McDuffs, (a family brewhouse).

Then, when we got home, Terran took a bath and we noticed dark purple bruises on him. We asked how he got them and he said he did not know. His nosebleed still had not ceased.

I tried to get the nosebleed to stop before bedtime by asking him to put some tissues up his nostril for 5 minutes. It did not help. In the back of my mind I knew this was not right and that it should have stopped, but did not really think about it. I figured it would stop by the morning.

In the night he woke up and came into our bed. His nose was still bleeding and his face was covered with blood. I cleaned him up and popped him into bed. When we woke up, his nose had a big bloody mass in it so I took him in the shower with me in the hopes of getting it out. It seemed to hurt him, so I did not press it.

Then, when we got out of the shower, something clicked in my mind. The bruises and bleeding were related. Karrie got up and stated the same conclusion. I had to get to work, so I asked her to clean his nose out and apply pressure for 10 mins to stop the bleeding.

Later on at work, Karrie called and said she was taking Terran into the hospital. She had tried the pressure and it did not really work, and then Terran went outside with the girls to play. When he came back in, he had even more bruises. Since we had both come to the conclusion that the bleeding and bruises were related, this was enough to warrant a phone call to the hospital. When she described what was going on, they made him an appointment for that afternoon.

Now, as you can imagine, after receiving the call from Karrie at work, I started Googling 'bleeding' and 'bruising' and was getting pretty worried. It was hard to concentrate on work. The Googling yielded all sorts of information -- including that bruising was one of the symptoms of leukemia! Now I was freaking out. I also saw lots of references to ITP, and the symptoms were so similar that I was pretty sure that had to be it -- so that calmed me a bit.

A few hours later Karrie called and told me it was indeed ITP -- whew! The doctor had instructed Terran to start taking a steroid called prednisone to suppress his immune system for the short term. This will stop it from destroying the platelets in his blood and get his platelet count back up. Platelets are what enable one's blood to clot. His platelet count was 2000 -- the normal count is 150,000 - 400,000.

Now, a few facts about ITP are in order: In children, 80% - 90% of cases are acute and last up to 6 months max. No one knows what causes ITP, but it occurs most often after an illness, (Terran had the flu last week), or vaccination, (we don't vaccinate the kids). It is a disorder and not a disease. It is like hemophilia, only not genetic. (If you have hemophilia, you have it from birth).

More info here:

So it's Tuesday night now and Terran's nose has finally just about stopped bleeding. I have the humidifier going in the bedroom to help it out. He feels just fine and seems to not be having strong side effects from the prednisone. He's covered in bruises. He needs to be super careful and not run around. I can't even pick him up without bruising him.

He's shown and exceptional amount of maturity and understanding for the situation beyond anything I've ever seen before with him. I'm really proud.

We're keeping him busy with Lego, Bionicle, board games, drawing, movies, clay/playdough, etc. Anything that does not involve climing and running around. He had a tough time learning to swallow the pills, but we worked out a system where he takes it with a scoop of ice cream :) He's a pro now.

He'll have to take blood test pretty regularly to watch his platelet count. The treatment for the disorder is basically to keep out of harms way and getting the platelet count up. The
prednisone should reset his immune system and help him to do that. The drug is a short term thing.

So, send good vibes Terrans way. He's a great little guy.

Saturday, March 05, 2005

Aanan's New Glasses

Originally uploaded by jeremyx.

Aanan got her new glasses. Here are some pics.

Sunday, February 27, 2005

Aanan's new bed

Aanan's new bed
Originally uploaded by jeremyx.

We got Aanan a new little persons bed for her birthday. In this pic you can the mattress and the purple fuzzy bedding that Grammy got.

We are setting the bed up under Terran's loft bed and hope to transition both of them into that room before too long. Then all three children would be sleeping in one room and Karrie and I could be, (gasp), alone in the other!

Evil Aanan

Originally uploaded by jeremyx.

I know Ive done something to offend when I get this look from Aanan

Wednesday, February 23, 2005

My baby girl is 3 today

Fall 2003 024

What a cutie! (Click the pic for a larger version)

Sunday, February 20, 2005

Aanan needs glasses


So it looks like Terran is the only child to have avoided the curse of his father's horrible vision.

We noticed a few months ago that her eye was turning in at night when she was tired. I made an appointment with the Ophthalmologist then. Over the next two months, her vision got drastically worse. Her eye was turning in all them time and it was obvious that she could not see anything very well.

So last week the appointment finally came and I took Anaan to the Pediatric Ophthalmologist and she had an exam. (It actully took a few appointments because she did not want anyone looking into her eyes -- after we forced drops into her eyes that make them dilate. But that's a whole other story altogether).

So we got the appointment done and ordered her a pair of glasses. They should be in by the end of the week. I can't wait for her to be able see!