Blockitto Development Thread

The lag spike is probably just the SD reading times. SD cards are tricky beasts.
If you’re willing to post some of the relevant code, some of us could probably take a look at it.

2 Likes

That’s actually not the case as I haven’t implemented file I/O yet. I figured it out, it’s that I’m calling my Perlin Noise function approximately 600 times when generating a chunk rather than the intended 30 times.

2 Likes

Oh right, I forgot the bit where you mentioned saving diffs and thought you were trying to write the generated world to the SD card like Minecraft.
(I’ve been familiarising myself with the MC 1.13 changes to the command system, so I’ve probably got Minecraft on the brain. :P)


By the way, do you happen to know if you’re using the 1980s Perlin noise algorithm or the 2002 ‘improved’ Perlin noise algorithm?

I’m only asking out of interest, I still don’t fully understand Perlin noise, I tend to get lost at the gradient vectors.

It’s an implementation of the pseudocode on Wikipedia, which is the classical 1980s one. I’m actually planning to write to the SD card next, after I implement the fix. Been busy with homework and I also want to play some modded Minecraft with friends today, but I’ll implement saving/loading when I have some time.

1 Like

But you’re not using floats as they are on Wikipedia, are you? You should use fixed point. There are also libraries, no need to reinvent non-trivial wheels, unless you want to learn of course.

Ah, I miss those days.
(Not the homework, but the having college friends to do multiplayer with.)

Shameless plug:

To get it working on Pokitto you just
swap out Arduino.h for Pokitto.h and #define FIXED_POINTS_NO_RANDOM.
(And I should really get back to sorting some of the issues some time.)

If you’re working for a big company writing professional production code maybe,
but if you’re working on a hobby project then reinventing wheels is always fun and education.
(Ok, maybe not quite always fun, but it’s always educational.)

3 Likes

Thanks for the library, will implement it when I have the chance! What exactly are the advantages of fixed-point in Perlin noise compared to floating-point? Just wondering so I can understand noise better.

1 Like

It is not for the noise, it’s for Pokitto. Pokitto HW doesn’t have a floating point coprocessor so it is emulated in the software, which is slow. Fixed point is much faster (it’s effectively just ordinary integer operations, you just suppose you’re counting with some smaller fractions, ctrl+f "scaling factor) and usually does the same job, so you should always prefer it on Pokitto.

2 Likes

Another shameless plug, have a read of my ‘A Fixed Point Primer’:

It explains what fixed point numbers are, why you would want them and vaguely how they work.
(It doesn’t go into details about how to add/subtract/multiply/divide etc, if you want to know that you can just read the code.)

2 Likes

I managed to get the lag time down to about 3-4 seconds using both my fix and @Pharap’s fixed point library. I’m thinking I may pre-generate several chunks around spawn upon world creation, and my chunk saving feature will make it so math isn’t needed for preloaded chunks (it’ll just read from a file) so chunks that you’ve already explored will be entirely lag-free. The game runs at a solid framerate on hardware aside from the terrain gen lag spikes.

2 Likes

I might be able to help shave a bit more time off if you post your perlin noise function(s).