Automating Level Balancing

So, got married, moved house, started an EPIC BIG GAME ™ (http://www.legendsoffore.com) and then realised I don’t have time at the moment to do it justice (of course I’ll be doing it). So I’m building a little game to test a bunch of stuff for the big game!

To the topic of the post, I’m building a game with levels, and monsters and all that good stuff, but a problem I always have is determining whats “hard enough” (fnarr). Balancing levels is always difficult especially when you’re appealing to wide range of players – if only there was a way to statistically define the difficulty of of a level?

For once, this time, I’ve designed my AI suitably generically – ok I didn’t mean to but I just spent a bit more time on it than before. The side effect is that the AI is smart enough to play for the monsters OR the players. So the first thing I did was make the game play itself. Brilliant to watch and found me a tonne of bugs straight away.

shot2

That was good, but then what – I mean I don’t want to take ages getting out the difficulty information and can’t really tell anything without a lot of runs.

Next step, make it run “headless” (for those who don’t know, that means without a display). Unfortunately a bunch of the data code I’m using from LibGDX actually depends on OpenGL (i.e. Tiled Map support). So – how to make LibGDX work in headless mode. First:

LwjglNativesLoader.load();
Gdx.files = new LwjglFiles();
Gdx.gl = new MockGL20();

Yes, I could have had the “headless backend” but its an awful lot to bring it for this.

So, now Gdx is initialised by whats MockGL20? I thought I’d have to bring in a Mocking library (like Mockito) but turns out all I needed to do was have Eclipse generate an empty shell implementing the GL20 interface. Boom! It’s done.

Now I can run a complete quest at top speed having it playing itself and evaluate the outcome. The output looks like this:

TEST RUN COMPLETED 'The Trial' (quest1.tmx)
QUESTS PLAYED: 100
QUESTS WON: 100 (100%)
QUESTS LOST: 0 (0%)
AVERAGE HERO SURVIVAL: 3 (of 4)

Excellent, I can now determine the first level is pretty easy – 100% wins from the player AI. Note thought that most of the time one of the heroes died – so not quite simple!

Hopefully this will help to balance out the levels and get their difficulty just right. Of course player feedback will help tune my understanding of the statistics coming out – assuming you guys play it!

 

Tags :
Categories : Code Games

Leave a comment