Sunday 8 April 2007

Trivia

As much as I loathe to bore potential readers with the daily inanities my mind conjures, today's random mind bullets are better than average, so I'll share. And this is my first attempt at a blog so I feel I've got a lot of catching up to do. They are also game related, so by sticking to my sworn theme I justify their telling.

Random Thought One: Funniest Gaming Experience

I was reminded recently of the funniest gaming experience I've ever had. I'm talking Grim-Fandago funny - that humerous. It was....(drum roll)....Chu-Chu Rocket on the Dreamcast, 4-player, with 3 colour blind participants plus normal-sighted me.

Now, I don't mean to make fun of the colour blind, my best friend is a ...etc. But as my gaming buddy Richard pointed out to me, almost 10% of the male population is colour blind to some degree. Which makes for some hilarious gaming-related hi-jinks. Chu Chu Rocket is the perfect game to play with colour blind people. 4 players, 4 different colours, and the ability to help as much as hinder your opponents (by accident, if not by design).

I can still feel my ribs aching from that day. I lack the vocabulary to accurately depict the chaos. If you ever played Chu Chu Rocket, I'm sure you can imagine.

Random Thought Two: Cutscene Vanity

One pet gaming peeve of mine is unskippable cutscenes. I always imagined (rightly or wrongly), that the decision was at least partly based on the fact that it was bloody difficult to get that cutscene working, so by Odin's Beard they were going to make you watch it. It has been suggested to me that the inability to skip the splash screen on Fish! is my own vanity playing up. I'll plead the fifth on that, and merely say that future versions will behave more in accordance with my own oft-stated gaming principles.

But I warn you, every time you skip that splash screen, a weighted-sum force flocking agent shaped like a fish dies.

Random Thought Three: Bring Back the Tank Rush

I love a good RTS. And by good RTS, I mean 'flashy, unstrategic RTS'. And by God and Sunny Jesus I hate micromanagement. Gaming buddy Richard and I speak of this regularly - he is the world's biggest fan of the unstrategic RTS. As he puts it - 'If I build 40 mammoth tanks, I sure as hell don't want them destroyed by 4 tiny crap 'counter units'. Screw that. The only thing that should beat 40 mammoth tanks is 41 mammoth tanks'.

Amen.

Friday 6 April 2007

Fish!

***Update 2*****

Thanks to Ziggy for spotting (and more importantly, solving!) the graphical artifact problem he was seeing. Source code and the installer has been updated with the new version, although it should be noted the changing renderstate (the solution involves turning the depthbuffer off during the water pass, then re-enabling it) within the draw loop may cause a minor performance hit, but not worth worrying about for now.

On a side note, I personally own 5 PC's of different ages/configurations. With close friends, I have easy access to maybe a dozen more.

And not one of them has an ATI graphics card. Could constitute a blind spot in my testing plan :)


*** Update ***

I've since wrapped all this up into an installer - FishInstaller.zip. It will install the .NET 2.0 Framework (if you don't already have it) and the XNA runtime, but you will still need a very recent version of directX 9.0c (December 2006 or later), as it has updated libraries that XNA requires. So if you can't get the demo to work, try updating your directX version - that's the likely problem. Apologies for that, no real way around it for now. Rumour has it that MS are currently working on a distribution technology to make this all a bit easier.

Here's the latest version of DirectX if required.
The latest DirectX 9.0c release. (45Mb)

***************

This is a little demo I wrote using Microsoft's recently release XNA framework. XNA is the spiritual successor to managed DirectX, essentially wrapping up directX and hiding some of the nastier elements from the novice coder, as well as providing a lot of useful functionality that's common to most games.

To run the demo, you'll need:

- A PC that meets the XNA framework requirements (the pertinent one being a graphics card that supports DirectX 9.0c and shader model 2.0 , which is pretty much everything from a Geforce 6 onwards).


Instructions
  • The demo begins with a simple splash screen, after the fish have demonstrated their literary skills you can proceed by pressing the Space bar.
  • The main demo is a simple enough sandbox, demonstrating real-time flocking behaviour based on Craig Reynold's classic flocking model. You have three constituent behaviours - cohesion (the force that attracts fish to each other), separation (the opposite), and alignment (the force that keeps them pointing in a similiar direction).
  • All the behaviours begin toggled off. The water effect begins toggled on.
  • Left mouse button spawns fish, right mouse button spawns obstacles (I know they're not particularly nautical, but I'm no artist as we can all see - pause it and zoom in on the fish if you don't believe me...)
  • You can change the strength of the constituent behaviours and observe the effects.
  • Arrow keys move the camera (top down, RTS-style), mouse scroll to zoom in and out.

Things to note

  • Classic flocking is computationally expensive (On^2), but there's a few tricks to get that down. A cell-space partitioning system is used here, so each fish only flocks with the fish in the surrounding few grid cells. Without such optimisation, this algorithm brings even a very powerful CPU to its knees very quickly - at around 130 fish on a E6600 dual core. With cell-space partitioning we can raise that several fold (depending on your CPU speed).
  • There's no actual collision penetration constraint here, only collision avoidance by the fish themselves. So you will see cornered fish clip through obstacles occasionally if the combined forces compel them to.
  • The water refraction effect is achieved by drawing the scene to a render target, applying this to a texture, and then perturbing and displaying this texture on a disc model that is placed between the scene and the viewer. Based on the 'refraction' effect found in Rendermonkey, if you're interested.

Finally, if you want the full source and all the trimmings - RainbowFishSource. The whole thing is really an offshoot of a simple game engine a friend and I are writing together. Hopefully should have some more to show in the coming weeks and months. Oh, and thanks to Gary Kacmarcik for his XNAExtras bitmap font code, a big time saver.