A Matter of Time

Hey Folks! Another mostly coding day today, slightly more productive than yesterday. Today's focus was mostly on time.

Initially, it was just some minor changes to make the player's life easier. I added code to make sure the plotter couldn't reverse time into the past, and it just "bottoms-out" at the star system's current time if you rewind.

I also added a timestamp to the orbit display's top right corner, which shows the current system time and the plotter's delta time into the future. However, this raised an interesting and (difficult!) question. How does time work in space, @2079? I decided that the time code is based on Universal Coordinated Time (UTC), and looks like this:


This is pretty familiar to most folks, but I made a slight change. Months always have 30 days in the game, and there are only 360 days in a year. This means that months still feel pretty much like Earth months, and there are still 12 months to a year, but we are no longer using the 365.25 days per year or variable days per month.

Part of this is to make record-keeping clearer and easier to work with, and part of this is to further establish the setting as having evolved from Earth's complex timescale. Technically, it's still a 24-hour day in the code, but we can all pretend it's been stretched to 24.35 hours per day in this setting, and a day per degree in a circle around the sun :)

However, that wasn't the end of my problems. Enter precision, stage left.

It turns out my simulation works fine for about 4 months, but soon, the clock stops ticking each second. And as months turn into years, we lose all clock activity. This is due to the way computers store numbers, which are limited to 7-digits of precision (for float numbers) and 15-digits for double precision numbers. Since Unity (and my game) were using floats to record seconds since game start, this meant that measuring things like years easily used up all the precision in the year/month/day end of the scale, and hour/min/sec changes were ignored.

Here's where I am now. One approach is to create a new class to handle each of these time units separately (rather like the Date class, except using this new calendar). Another approach might be to store all time as a double. I think a double would insulate us from enough precision trouble to exceed even the longest-lived ship crew. But that's math for tomorrow.

In minor news, I also found and fixed that UI scaling bug from yesterday. (Yay!) Turns out it was a simple flag I wasn't setting when creating those UIs. I also found and fixed a bug that caused planets to stay put on the plotter, while their future projections moved around. Again, simple omission in the code that I added.

Overall, a mostly productive day! Just not much to show yet. Hopefully soon!

Tags: Ostranauts


Marc13Bautista's picture

Quick question, will we be able to visit the DMC? ;) I've always thought about going to more places there aside from the ones already in Neo Scav.

Free Elusive Skill = Athletic x4 in ATN Enclave encounter

matsy's picture

I don't envy you tackling time. Can the format not be set regionally e.g. I can have it set as the UK format?

In terms of how it works in the game, I guess you plan to have a space time, and then a world time?

dcfedor's picture

@Marc, probably no Earth visits. Sorry :) One of the features of NEO Scavenger's universe is the lethal orbital space around Earth. Ablation cascade (a.k.a. Kessler Syndrome) and leftover defense satellites have rendered Earth orbit impassable, simultaneously locking people in and out.

@matsy, time will probably be strictly most-significant-first format in the game. If I'm going to muck around with time, I'm going to make it logical :)

As for space time vs. world time, space time will be the standard for anyone who travels (i.e. the player deals with this one). There may be some cases where the locals use their own time scale to match local celestial events (sunrise/set, orbital periods).

But it'd be crazy to expect a space crew to have to learn all the time systems for each of the thousands of celestial bodies and stations in the System. You want your cargo picked up? Specify location and date in the agreed-upon shipping standard :)

Dan Fedor - Founder, Blue Bottle Games

Marc13Bautista's picture

Sounds good! Hopefully there's a bit of a secret end-game where we could visit Earth (DMC) with a some sort of requirement. Would be nice!

Free Elusive Skill = Athletic x4 in ATN Enclave encounter

Malacodor's picture

Why not use integers for time?

+1 for logical time!

Ran around with a clown mask before it was cool

dcfedor's picture

I almost did! But Unity (and most game engines) track time in float seconds, with internally-reported per-frame deltas in the ballpark of 0.016-0.033s. And it was fairly trivial to switch the time record-keeping of the sim to double, so I just did that :)

Dan Fedor - Founder, Blue Bottle Games