Thursday, October 28, 2010

C# random number generator starts returning only zero

Yesterday my game AI started going haywire on me. At a random point, all of my creatures would start moving in a single direction.

Turns out the cause was Random.NextDouble starting to return only zero. And it turns out the cause of that was multiple threads accessing the same instance of the Random class.

As I would have expected had I thought about it, Random is not thread safe. If it gets accessed from one thread while it is in the middle of an operation for another, its internal state gets mucked up and it just spits back zeros from then on.

The solution is to use one instance of Random per thread (which is what I did) or to ensure synchronized access.

Wednesday, October 20, 2010

Throwing Rocks at Frogs



Exploding frogs - what's not to like about that?

Friday, October 15, 2010

Frogs in Block World



Slow week since my graphics card died on me over the weekend. I finally got up and running again last night.

To celebrate my new graphics card, I made some frogs.

Thursday, October 7, 2010

Block Model Editor

Terrain Rendering

I hate making editors. Creating an editor for a feature always takes ten times the amount of time that it took to add the actual feature itself. And it is much less rewarding code to write.

I need an intern...

Anyway, I've got a half-assed editor for the block models that I will be scattering throughout my block world. I used my mad 3D art skills to draw a tree. So there!

Monday, October 4, 2010

Block Models

Terrain Rendering

I am currently working on adding more details to my Block World environment. This will be done mostly through the use of what I am calling "Block Models" - meshes generated from a 3D cubic grid of "trixels".

I started with 16x16x16 grid and did a test to see how many I could render. Quite a few, it turns out.