Project Zomboid is an open-ended zombie-infested sandbox. It asks one simple question – how will you die? Whether surviving in Knox County free-roam or controlling Indie Stone mascot Baldspot in his quest to save his injured wife Kate – death is always a certainty. Quite how long you manage to put it off is another matter…

Report RSS On optimization and the passage of time…

Knox County evacuees, your attention please. The situation is now under control. Soon you'll be able to return to your homes, eat delicious Spiffo burgers, sip hot beverages in the local Seahorse cafe and walk through Muldraugh's verdant woodland. The Knox County incident is now under strict government control. The outbreak is contained.

Posted by on

Well, sort of. Thanks for your ongoing patience everyone, we're now down to four tasks that must be completed before release, and some nightmare pathfinding issues have been resolved with the help of countless gallons of coffee.

Another task that's now pretty much mission accomplished has been optimization. There's much more complicated stuff going on in the world now: making it more persistent with hordes that persist as real zombies instead of virtualised versions, and who always collide with each other to prevent stacking problems, had been pushing up the minimum spec of the game far too much. When you factor in NPCs capable of navigating to any point in a more substantial map and new features like pushable
furniture there was a real danger that we'd start to lose a large chunk of the bottom end of our current customers.

While we've warned that this may happen, it felt like we were in a danger zone: too sudden a change for the customers who've waited so patiently for us to sort our shit out and get them their much awaited
new dose of Zomboid.

So in the recent parts of the task-list some heavy duty optimization offensive went into effect. The thing is that, as any programmer will tell you, optimizations are a mixed blessing. Sure, they speed the game
up a lot - but on the flipside making odd changes to the code to eke out extra performance can lead to obscure and messed up bugs. In the recent tasklist slowdown we fell victim to this: new and deadly bugs had to be fixed. Stuff that was working perfectly well in our demonstration videos as CPU hogs subsequently needed more attention.

We've now pretty much broken through this barrier. A massive part of the tasklist has been these bugs: some taking days of head-scratching to sort out. Still, optimization has been an ongoing concern. With a lot of people complaining of lagging in the current version, in all honesty it's been borderline terrifying.

In recent days, however, we've had an epiphany. We've realised exactly why speed and CPU power have been such an issue, and with it has come a solution.

See, unlike most games, PZ has been more taxing on your computer for one reason alone: fast forward. Having to process the entire world 3,600 times each frame to achieve the required speed to wile away the long nights barricaded in your safe house meant that even one CPU hungry process could knock the fast forward speed down to depressing levels. THIS is why we've had such a problem (more so than many other games of our ilk) so instead of breaking the code with optimizations that would be dangerous to our stability we've decided to approach it from a new angle.

You know in Skyrim where you choose to 'wait'? The task we've almost completed is us doing that. Instead of processing the world a million times a millisecond, we're going to cheat massively** and hopefully achieve a comparable effect. Let's say you've snuck back to your safehouse and hammered up a plank of wood, you're not tired and you've decided to sit it out until morning. Clicking the new 'wait' icon and the game will go into 'ULTRAWAITSUPERMODE' (TM).

'ULTRAWAITSUPERMODE' (TM) will persist until you unclick it, or you make visual contact with a member of the living dead. In this mode we'llonly draw the frame once per hour or so, speeding up the clock and day to night cycle essentially fast-forwarding time. We'll make people get hungrier or sleepier faster, we'll make zombies and NPCs walk and run much faster, and basically supercharge everything in the game. In terms of you playing the game time will be perceived as being sped up, when in actual fact its just things in the world moving at ridiculous speeds, while the computations required are still only happening as they do at normal speed, massively reducing the strain on the CPU. This won't be a perfect simulation by a long shot and may have some side-effects in itself, but will hopefully (as early tests indicate)
be imperceptibly different to actually fast-forwarding time properly as it currently does.

Yes, it's technically a massive cheat **, since per hour technically the AI is capable of doing a fraction of what they would be able to normally. But they'll do it all at ridiculous superman speeds to compensate, and that will massively free us up from the shackles of optimization for this update, and all updates to come.

While this is technically an 'extra task', one of those other remaining tasks is 'optimization', and trust us when we say that task has taken about 100x the time of any other task and probably would
continue to do so without this solution.

On a decent spec PC we can now fastforward through an entire night in about 20 seconds, compared to the couple of minutes it previously took (yes, eek indeed). This has been a massive part of our tasklist, and we're overwhelmingly relieved that we've worked out a way to keep the low-end PCs of PZ players happily infected when the update comes around.

Thanks for reading everyone! We'll make some new videos as soon as this part of the code has been beaten into shape!

** We should clarify at this point that the word 'cheat' should not be confused with it being a hacky crappy way of doing things unique to our game. All games 'cheat' massively at every possible opportunity. For
example, it's highly unlikely that Skyrim's wait mechanic runs the game at 1000x speed while you're waiting. Just fast forwarding time was never initially intended in the game, and the way the feature was added and evolved meant this approach didn't happen from the get go, as it perhaps would have done if the feature was pre-planned before development.

Post comment Comments
TopHatMcFenbury
TopHatMcFenbury

Wooh good job guys! Can't wait for the new update! I know you probably don't care, but I really appreciate that you guys did not give up and are trying your hardest, which is more than what most indie developers would do.

Reply Good karma Bad karma+21 votes
Aarkreinsil
Aarkreinsil

Soo will this be enough to push you over the beta edge?

Reply Good karma Bad karma+1 vote
Dr.Goupyl
Dr.Goupyl

Mmm... personally i don't think so but we will see that soon !
I think Beta can be for the co-op mode but it might be a lil' early^^

Reply Good karma Bad karma+1 vote
WarTurkey
WarTurkey

Is this only if you have lag while speeding up time or lag in general because I have lag in general?

Reply Good karma Bad karma+1 vote
tristan371
tristan371

my computer is pretty terrible (somewhere between a worn calculator and a half eaten sandwitch) and i dont get any lag when i fast forward...

Reply Good karma Bad karma+1 vote
Rohan15
Rohan15

I freaking love you...now can you please add a save mode? :D

Reply Good karma Bad karma+5 votes
VandalSQ
VandalSQ

PZ You are doing this right !

Reply Good karma Bad karma+2 votes
CanadianWolverine
CanadianWolverine

I know I appreciate this level of honesty, getting to peek behind the figurative curtain. I don't mind the wait, I can be patient.

Reply Good karma Bad karma+1 vote
bolt0009
bolt0009

Honestly I cannot wait for this update I played for weeks before deciding to buy it, and still do. I really appreciate how much work you seem to be putting into this game, because i've read the zombie survival guide as well as meany other sombie books watched movies and all that...
This is by far the closest game ever to come with the elements of true zombie survival Thank you :D

Reply Good karma Bad karma+1 vote
SIGILL
SIGILL

So you were actually, truly fast forwarding game? In wait mode the PC performed every calculation it normally would, but a lot more times per second? I'm not a professional coder (yet), but that doesn't sound like a great solution in the first place does it? (although it is the moest realistic one of course) :P I'm glad you've found out a way to make every run faster though!

Reply Good karma Bad karma+1 vote
lemmy101 Creator
lemmy101

As we explained in the post, that feature was implemented way after the game engine was already written and doing it this way requires a lot more work than simply calling 'update' multiple times. ;) And at the time little enough was going on that this was the best way.

Reply Good karma+2 votes
Muffalopadus
Muffalopadus

Hey, keep up the good work guys. I can't wait to see what you've been cooking up in this next patch. =)

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: