Leave a comment

Stress tests

The title isn’t really that correct, but it seems better than “automated tests”.

As I prepare Tank Negotiator for play testing, I needed to revisit the network multiplayer code. I’ve made a lot of changes since it was last tested properly, and I’m not confident I haven’t broken anything.

Moreover, I wanted to exercise it quite completely without much effort on my part.

As much as possible I try to exercise the network multiplayer code during regular non-network play (e.g. by sending the data packets anyway – just that no one listens to them). Of course that’s not enough though, and setting up a real network session with friends is a pain. Setting something up between my PC and Xbox with just myself is ok, but it’s hard to play two controllers at the same time – meaning I’m not really “playing” the game, and so I’m not exercising much code.

So I decided to write some automated (but random) logic that generates reasonable controller input. By reasonable, I mean that it is sufficient to exercise a lot of the code in the game, even if there is no AI behind the input (I’d tried to write AI for Tank Negotiator previously, but decided it was too big of a task).

Basically, it sends the player’s tank off in different directions every few seconds, and randomly presses all the various buttons that do things (fire weapons, activate skills, pick up the flag, etc…). The gameplay looks like a bunch of drunk monkeys are involved, but it serves its purpose and only took a few hours to code up.

Basically, I set up the network session manually between PC (1 player) and Xbox (3 players), press a key and suddenly the monkeys take over. It gives me confidence that my game can run with tons of stuff happening for 30 minutes at a time. Already, in the course of an hour or so, I’ve found a number of critical bugs. Some of these didn’t even involve networking, but weren’t found in many many hours of local play-testing.

One particular bug manifested itself as a hang after about 30 minutes of gameplay (a normal game takes anywhere from 5 to 10 minutes). I thought I might have caused some sort of crazy out-of-memory condition on the Xbox or something, but – luckily – breaking into the debugger dropped me straight into my code and a few minutes of code inspection revealed the problem.

Here’s the scenario: A laser is shot out of the player’s tank, and bounces off walls. The following code is a very simplified version of the real code which tries to trace out the laser’s path as it bounces from wall to wall. It has a major problem which hours and hours of gameplay never demonstrated, but the stress test did. What is it?

 float laserLength = 30f;
 while (laserLength > 0f)
 {
     // Do some collision detection
     float distanceToWall;
     if (LaserHitsWall(out distanceToWall)) // distanceToWall is guaranteed to be a +ve floating point number.
     {
         laserLength -= distanceToWall;
     }
 }

Highlight the text below for the answer:

The problem is that this line may not do anything due to FP precision limitations:
    laserLength -= distanceToWall;

Even if distanceToWall is positive, subtracting it from laserLength might still result in laserLength if laserLength is large enough, and distanceToWall is small enough. If we get into some situation where the collision detection keeps returning the same tiny value for distanceToWall, we never exit the loop.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Space Quest Historian

Let's Play's, Podcasts, and General Adventure Game Goodness

Harebrained Schemes

Developer's blog for IceFall Games

kosmonaut games

Development blog of "Bounty Road"

Halogenica

Turn up the rez!

bitsquid: development blog

Developer's blog for IceFall Games

Game Development by Sean

Developer's blog for IceFall Games

Lost Garden

Developer's blog for IceFall Games

Memories

Developer's blog for IceFall Games

Casey's Blog

Developer's blog for IceFall Games

Blog

Developer's blog for IceFall Games

Rendering Evolution

Developer's blog for IceFall Games

Simon schreibt.

Developer's blog for IceFall Games

Dev & Techno-phage

Do Computers Dream of Electric Developper?

- Woolfe -

Developer's blog for IceFall Games

Ferrara Fabio

Game & Application Developer, 3D Animator, Composer.

Clone of Duty: Stonehenge

First Person Shooter coming soon to the XBOX 360

Low Tide Productions

Games and other artsy stuff...

BadCorporateLogo

Just another WordPress.com site

Sipty's Writing

Take a look inside the mind of a game developer.

Jonas Kyratzes

Writer, game designer, filmmaker.

%d bloggers like this: