ferrous26 / cs452-flaming-meme

CS452 Real Time Programming
MIT License
2 stars 1 forks source link

Velocity data for each track segment #106

Closed ferrous26 closed 10 years ago

ferrous26 commented 10 years ago

14 speed levels, 5-7 trains, 155 track pieces

That is 43kB of velocity data. Is it worth it?

ferrous26 commented 10 years ago

That is, about 8.5 kB per train.

ferrous26 commented 10 years ago

The other option is to have some sort of scaling factor for a base speed associated with each track node. However, we would need to do some more measurements to see if the same multiplier will work for each speed level.

If only it could work with each train, it would be a definite winner.

ferrous26 commented 10 years ago

The answer is "no, 43kB is not worth it.".

Since we know that train velocities have a linear relationship we can exploit that to only store the slop and offset for the line. This reduces the storage requirement to 2 words. To handle live feedback we have a slope and offset for each track type, and also a delta offset that we build up using feedback. Still linearly bound in size if we should choose to have one function for each track node, but the constants are much smaller:

144 track nodes
3 words per node
-----------------------
432 words
1728 bytes

Still a big deal and we should avoid it, but an order of magnitude less storage required.