TinyModularThings / Chunk-Pregenerator-Issue-Tracker

Issue Tracker & Wiki For Chunk Pregenerator
15 stars 0 forks source link

[Question/Wiki Clarification] Fastgen accuracy is 90% statement #4

Closed coderepo8593 closed 1 year ago

coderepo8593 commented 1 year ago

When you say the Fastgen's algorithm is only 90% accurate, what are you measuring?

For instance, do you mean that the check it runs is only 90% accurate to detect chunks that have already been generated? Do you mean the generation is only 90% accurate when building according to the worldgen parameters? What are the ramifications of the 10% miss? Are they false negatives, false positives, or some kind of mix?

I can't tell by the ambiguity of the statement of what exactly it is referring to.

Speiger commented 1 year ago

The Fast Check algorithm doesn't use chunks to determine if a chunk is fully generated. Instead it uses the RegionFile headers and knowledge on how Worldgen happens to determine that. But the RegionFile headers do only contain the info if a chunk exists, not what state it is in.

Basically in 1.12 for example you need a 2x2 area to fully generate a chunk. XY YY

X => chunk you want generate Y => Chunks required to generate X

And what chunkpregen does is check if around any of these 4 chunks, in a + pattern, is a missing chunk. If there is no missing chunk then it thinks that that chunk is fully generated.

The 90% accuracy comes from a scenario where you have this.

XXXX XYYX XYYX XYYX XXXX

X => Fully Generated chunk Y => Partially generated chunk (terrain only, no ores/structures/trees/etc)

This is the one scenario where chunkpregen can not see that the chunk wasn't generated with FastCheck. But these are rather unlikely and or can only be created in very specific cases. I am saying 90%, even so it could be 100% or 99.999999999% or 5% accurate if you world has a lot of edge cases.

Why did i implement it this way: Because it is thousands of times faster to check millions of chunks for a slight possibility that it has false positives. To fully check a chunk it takes a few milliseconds to a few seconds, to check a chunk with the region header it takes nano to micro seconds if a proper cache is provided.

I hope this answers your question.

coderepo8593 commented 1 year ago

Yes it does answer my question. Thank you very much. So we could get a false positive on the check where it recognizes a chunk has been generated when it is actually only partially generated. It's also seems safe to say that for an entirely new world in which only the first initial chunks have been loaded due to player entry, the fast check will be 100% accurate.

Speiger commented 1 year ago

Yep, and since the edge cases are extremely rare fast check gen is the default. (Your hardware will thank you too... Minecraft isn't known to be hardware friendly)

Also a false positive is just that a few chunks need to generate, which can cause lag but in 99% of the cases you wouldn't even notice that 1 chunk that wasn't generated.