The 3 Main Systems
Home -->
Programming Projects -->
Fractal Block Engine -->
The 3 Main System
The 3 Systems
The fractal block engine has 3 essential components:
- The Active Chunk Tree System
- The system to load and record changes to the world
(The Chunk Changes System)
- The system to procedurally generate a chunk
(the Procedural World Generation System).
The Active Chunk Tree System
is significantly more complex than the other two.
System 1: The Active Chunk Tree
At any point in time the game can only interact
with a few thousand chunks.
These chunks form what we call the
active chunk tree.
When a chunk is added to the active chunk tree,
we first procedurally generate the chunk from
scratch
(using the Procedural World Generation System)
and then we load any modifications
to the chunk (using the Chunk Changes System)
that have previously been saved.
Later, we may remove a chunk from the active
chunk tree.
System 2: Chunk Changes
As described above, when a chunk is added to the
active chunk tree, we must load any modifications
to the chunk that have been previously saved.
These modifications are stored in what we called a
chunk changes object.
If during gameplay a chunk is modified,
this change is stored in a
chunk changes object
associated to the chunk.
Even if the chunk is removed from the active
chunk tree, the chunk changes object remains.
No changes are made permanent until the
user saves the game.
When this is done,
all chunk changes objects are written to the file system
(into chunk files)
and then we remove all chunk changes objects.
System 3: Procedural World Generation
The procedural world generation system
is responsible for generating a chunk from scratch
(before any modifications to the chunk are loaded).
This procedural generation is pseudo random
in that if we return back to the same chunk later,
it will be procedurally generated identically
to the way it was before.
The procedural generation of a chunk C
uses a seed for random number generation.
The seed consists of 1) the path of C
from the root of the chunk tree,
2) the block type of both C and of each ancestor chunk
of C, and 3) the block types of the
chunks in the 5x5x5 region of chunks
surrounding C.
Comment About Reloading
When the player starts up the program and loads a game,
a fair amount of data needs to be loaded and processed
by the engine.
However if the player plays the game
(without saving) and then wants to load the game again,
we should not need to reload much of the data
already loaded.
We will not stress this point
and will leave it up to the reader to figure out
how to accomplish this.
Something to note is that each time the game is loaded,
we DO fully reload the active chunk tree.