Game Design, Programming and running a one-man games business…

Debug Tools and defensive AI.

Life is so much simpler when you bunch up all your hotkeys and toggles for debugging the game into a single menu. I feel like I have a rough idea what’s going on now. I also feel more confident about coding decent defensive AI when you play as the attacker:

The code for defending basically needs to manage three things. The play style (Is it spamming units, hoarding points, or steadily placing), The choice of units (Does the enemy have units weak Vs lasers? Are there lots of infantry needing flamethrowerising?) And the choice of unit placement. I’ve been concentrating on the unit placement debug UI today, so I can see what the AI is thinking when it chooses to place a turret at X rather than Y. More work to do, but currently it evaluates proximity to enemies, their size, victory-point value, closeness to the exit and proximity to the placement, plus it also has bonuses for being able to cover multiple paths from a single location.

It all needs lots of tweaking and balancing obviously, but it’s getting there. Attacking AI is much simpler.

After getting this stuff done, I’m thinking of experimenting with a unit ‘cooldown timer’ beyond a certain level to prevent spamming the same unit everywhere. Essentially there are supply delays if you plonk down 4 heavy tanks all very quickly, as new ones need to be dispatched from your offscreen HQ. I think it might be a good mechanic that encourages variety.

Shadow maps make me happy

I’ve been watching some WW2 footage, some war movies, some video game footage, etc, in a bid to up the visuals in GTB. A lot of it can’t be seen in a screenshot, it’s moving-picture stuff really. UI’ve also been re-visiting how I make the shadow maps, and massively boosting their resolution. What PC’s can’t handle a 2048 square texture these days? None, I suspect.

Anyway here is a very sparse GTB screenshot:

And here is the same frame, but without the shadowmap.

I think the shadowmap wins by a huge margin. (It’s more apparent full screen, when moving and zooming etc. Combining a grayscale shadowmap with tileable textures not only makes it look less 2D, but it also means you can detect the repeating tile patterns a lot less. I am using a tile-based system to afford easy level design for players. I’m also toying with the idea of automatically generating the shadow maps from the player-designed paths. I think it’s quite doable, although non trivial, and better than expecting players to use photoshop etc.

Comments?

Running to keep up

About 8 years ago I was chatting to the receptionist at a games company I worked for, and she was telling me about a conversation she had recently with the lead coder (and general all round engine god) of the company. He had been working late (as usual) and looked up at her, a bit vacant and said “I can’t handle this any more”. By which he meant the long long hours of coding, coding, staring at a screen (he had 3) and pouring over complex algorithms to get the code to be faster, faster… He wasn’t an 18 year old student any more, and it hit him really suddenly.

That’s kind of the whole lifestyle trying to keep up in the world of game production.

It’s not just games. I remember a quote by Glenn Tipton, guitarist for Judas Priest, where he said he loved the new wave of neo-classical heavy metal guitarists, because even in his forties, it meant he couldn’t put his feet up and know he was good. They were always pushing him every year to be faster, flashier, better.

There's always someone who can play faster than you...

I’m sure it’s true in every field, weight lifting, (any kind of sport really), comedy, writing… the pressure goes up and up each year. In order to suceed, you need to be better than the people who came before, and every year, the cumulative pile of stuff that came before gets bigger and better.

I am VERY aware of the fact that you can go to steam right now and buy a lot of once-big-budget games for the same price as buying one of mine. I’m not trying to play AAA games at their own game, but I’m trying to keep my games as fresh and modern and polished as I can. The harsh fact is, I can’t expect to make a game that’s just *as good* as Gratuitous Space Battles, and expect it to sell as well, three years later. That’s planning to fail. I need to address every single thing I know was wrong with GSB, and if I achieve that, I expect to maybe match that games sales, nothing more.

So in comes better online integration, achievements, better unlocks, hopefully better user customisation. Better artwork, better all-over-polish, better play testing and bug testing. And that means hiring more artists,  spending more time, being more obsessive with detail. This is not an easy gig. This is anything but an easy gig. And yet I love it. When I tried the battlefield 3 beta, I was noting everything that impressed me about it, knowing I need to get that sort of detail into GTB. When GTB comes out, BF3 will be old news. It will be yet another rung on the ladder of what gamers expect.

Note: I’m not just talking about graphics. I couldn’t begin to compete with the shaders and the pixel-pushing power of the frostbite engine. I’m talking about polish, all those little things that make games more playable, approachable, long-lasting and easy to use. Stuff like animated menus, text that nicely fades in and out, and is pin-sharp. intuitive GUI’s that are in just the right place, taking up just the right amount of space. Really well thought-out color palettes, sounds that all seem to fit together, flawless execution of UI stuff, great tutorials etc.

Back to work…

Anatomy of a gratuitous bug

I think I’ve fixed a bug in the gratuitous space battles campaign game. I’ll know ‘officially’ soon, but it fixed it on my machine :D Here’s what was involved.

A player complained of a random crash bug at the end of some campaign battles. I could not ever reproduce it, and back-and-forth emails began. Eventually, this awesome customer provided me with exact steps to reproduce, and all their save game data to let me replicate it. First run through and….. nothing. It was fine. Roughly every third run-through, in release mode it crashed…

Step 1! Hurrah! it actually crashes for me. This is 50% of the battle because then I *KNOW* that it is the games fault, and not the gamers system, or software. This is good, although frustrating news.

Step 2! It crashes in debug mode. This is another 25% of the battle because I can actually see what data is corrupt. As it turned out, the ‘firstfleet’ pointer in the code that assigns captured ships to the players winning fleet is clearly trashed. How did this happen?

Step 3… debugging. It transpires that the firstfleet pointer is accessed multiple times before this point, and after being initialised, confirming that it *must* have been valid, and becomes invalid between initialisation and access when adding captured ships to the fleet. This means we  can step through and watch what happens, if I break on initialisation..

Step 4 discovery! Stepping through the code confirms my suspicions. Once the battle ends, the code updates all the players fleets and removes ships that died in battle. Then, other code innocently picks the first of the players fleets in the battle, and initialises a dialog box listing the enemy captured ships that will be assigned to the fleet. Later…. *drum roll* it deletes any fleets that are now empty. Can you see the bug yet?

Step 5: fix! Changing the code that naievely picked the ‘first fleet’ to pick the first player fleet that still has some intact ships ensures that the later deletion of an empty fleet, and invalidation of the pointer is harmless, because the captured ships are now getting added to a surviving fleet. Bug probably fixed, pending the player confirming that a new exe fixes it.

Why did I not spot this bug six months ago? Well here is what has to happen.

  1. The player has to fight a battle with multiple fleets at once (common).
  2. He has to win (fairly common)
  3. The ai has to lose by the right margin to leave some captured ships (fairly rare).
  4. The winning player has to have enough ships removed from the *first* fleet in the list to have that fleet entirely deleted, despite winning overall. (pretty darned rare).

Simply put, This didn’t happen to me once in testing. It hasn’t happened to many players either, as I understand it. And if it has happened to you… I may have good news :D

Regimental colors

Today I got a decent chunk of work done for the regimental colors editor for GTB. GSB only had your user name, which didn’t really add a feeling of connection to the other player, so GTB will have your regimental logo (like a cap-badge insignia) associated with your maps and armies, so hopefully players will feel more like they are really fighting against proper opponents.

I plan to support user-designed, uploaded logos too, but because 95% of players won’t be arsed to do that, there is a simple editor that arranges a logo out of 3 layers and renders it to disk as your profile logo. The rendering isn’t done yet, but the rest is:

You can choose between a bunch of graphics and the three layers get combined, with a choice of some colors, plus you can move elements up and down and scale them. It’s the bare minimum that will give me an assurance that you will generally see fairly unique logos for all your opponents when playing other players armies. Plus it was fun to do :D

The problem with code like this is you can get *too* into it. I could happily spend a week doing a fully featured military insignia designer with a ton of features, but you can’t have that attitude with a game as huge as GTB if it’s ever going to ship :D I really hope the game does well enough for people to get into designing really cool logos. GSB has a great modding community and I’d love to see them go to town with stuff like this.