How Does Mining/Exploring Work?
Planets are pairs of
(x,y) coordinates (1003,-232). A player's computer will look for the next undiscovered
(x,y) pair near them and then runs a hashing function with the
(x,y) as input and the output is a locationId hex string like
0000000e0fd5a8d9fb6a29ad158aadaad0ef579ee5e4d3fa0a4ef8761d41b873. The game has rules that decide which of these hashes become a "legal" planet -- most aren't! This string defines everything about the planet!
Note that the blockchain contract doesn't know about any of the infinite amount of planets that might exist at
(x,y) pairs. Each player is looking for planets by exploring the fog of war, but the contract still doesn't know about those until someone sends energy to one of them and they're finally tracked in the contract. This is why after the game has been running for some number of days/weeks/months, it takes longer and longer for the game to initialize. The contract now knows about every planet anyone ever interacted with, even if they didn't beat the pirates!
The MIMC hash function is fed a different configuration each round so an old map isn't generally reusable between rounds (unless the same configuration were to be reused).
Every user shares the same hash function so Player A's
(0,0), when hashed, will be the same as Player B's
(0,0). The whole point of hash functions is that it's impossible (or incredibly difficult) to somehow figure out what a player's
(x,y) was from the planet hash.
When a locationId is submitted to the blockchain where everyone can see it, they know that something is being done somewhere, but they don't know where (unless they've also already hashed that same
(x,y) in their local database). Each player's database of hashes is only stored locally in their web page storage and isn't synced anywhere else!
This is why a player will have a missing map when logging into Dark Forest from a new browser or device.
What is Lazy State?
There are no timers counting down silver or energy growth nor watching for arrivals to land in the smart contract.
The clever way this is implemented by the developers is to store planet statistics like energy as a lastUpdated timestamp, and to perform all energy calculations lazily. When a voyage is made, the contract is updated, however when a voyage lands on a planet nothing happens. The next person who tries to interact with that planet will pay the gas costs to fast forward the planet’s energy levels from the old timestamp to the new timestamp, and then schedule their arrival!
As a result, planets in the contract actually don’t show the most recent owners or energy - it takes a smart game client to apply all the history of arrivals and fast forward to the current time.
The contents of this article are up to date for Dark Forest v0.6 Round 1.