Dark Forest Birth Point and Map Randomness

The fun of Dark Forest mostly comes from randomness, and the randomness built into the game mainly comes from the following areas:

  • The player's birth point
  • The random distribution of the in-game map
  • Unpredictable interaction between multiple players
  • The random opening of artifacts with different effects

In the previous article, we discussed examples of artifact mining randomness being hacked by players, and this time we'll discuss the first two randomness: player birth points and the random distribution of in-game maps, which were also able to be hacked by players in versions prior to Dark ForestV0.6R3 and could create advantages for players in the early game.

1、Map randomness

Player phated has announced a method to explore the map in advance and freely choose a birth point at the start of the game, and has provided a website for exploring the map in advance. Through this method, players have gained some first-mover advantage in the game, and the impact of this advantage on the overall nature of the game has yet to be evaluated.

Since the map in the game can be explored in advance, the birth point can be chosen, then certainly, or randomness has a problem, from the game code, we can find out where the problem is.

I think the most attractive part of Dark Forest game is Fog of War, although Fog of War is not a new concept, but Dark Forest combines Fog of War and blockchain in Zero-Knowledge way, combining these two opposite nature (hidden and public) together, which makes Dark Forest unparalleled unique charm.

Since Dark Forest is a Cryto-Native game, all data and operations are stored on the chain, which means that all planet coordinates and player operations can be queried on the chain, but then Dark Forest becomes a full information symmetric game, which loses a lot of fun, so Dark Forest does not store planet coordinates directly on the chain, but stores the hash value of planet coordinates, which can be considered that Dark Forest encrypts the planet coordinates by means of hash calculation.

Since the planet coordinates stored on the chain are encrypted by hash, when a new player enters the game, he cannot find out the coordinates of any planet except his home plant (all other areas are covered by the fog of war), so the player needs to explore the universe by constantly performing hash calculations. The basic principle is that the player on the client side do hash calculation for each coordinate value (x,y) in the universe , and come up with a hash value, when the hash value is less than a specific value, it means that there is a planet at the coordinates, Dark Forest in the hash value of the judgment code is as follows.

hash.lesser(LOCATION_ID_UB.divide(planetRarityBI))

Where LOCATION_ID_UB is a fixed value, in the current contract :LOCATION_ID_UB="21888242871839275222246405745257275088548364400416034343698204186575808495617"

planetRarityBI is a value that can be adjusted at the time of contract deployment, by adjusting the size of this value, the density of planets appearing in the universe can be changed, for example in V0.6R2 the value is 16384, we can get this value by entering df.planetRarity in the console, since the hash function can be seen as a random prediction machine (i.e. hash function generates a value that is uniformly distributed).

Then we can calculate that when the hash value is less than this number below, it indicates the existence of a planet at this coordinate point: 0000c19139cb84c680a6e14116da06056174a0cfa121e6e5c2450f87d64fc000

Because there are 4 zeros in front of it, the probability of a planet appearing at a single coordinate is about one in four to the tenth power, or one in ten thousand. For a circular universe with a radius of 30,000, the area is π*r², and divided by the probability of a planet appearing, about 280,000 of plants will appear.

After determining which locations the planets exist, the next step is to determine the type and level of the planet. Dark Forest uses the Perlin function to generate different space and biological types. There are two main inputs to the Perlin function, one is the coordinates (x,y) and the other is the key value, including SPACETYPE_KEY (for space type generation) and BIOMEBASE_KEY (for biological type generation), and the Perlin number of a planet can be calculated by the following code.

perlin: perlin({x, y }, spaceTypePerlinOpts),
biomebase: perlin({ x, y }, biomebasePerlinOpts),

The type and class of the planet are then derived from the Perlin number.

planetLevelFromHexPerlin(hex: LocationId, perlin: number)
planetTypeFromHexPerlin(hex: LocationId, perlin: number)

From the analysis above we can know that after knowing the planet coordinates and the Key of the Perlin function, we can derive the type and level of the planet, so the only thing that affects the randomness distribution of the whole map is df.planetRarity and the two Key values, after knowing these values, the map of the whole universe can be calculated, so as long as the contract is deployed and can check these values, the Players will be able to explore the map through the server they set up, which is the reason why phated is able to explore in advance. In the current version, these values will be reset after the contract is deployed, so it is not possible to explore in advance.

2、Birth point randomness

The problem is relatively simple, and the code to select the planet of birth is as follows.

planetPerlin < initPerlinMax && 
planetPerlin >= initPerlinMin && 
distFromOrigin < this.worldRadius && 
distFromOrigin > spawnInnerRadius && 
planetLevel === MIN_PLANET_LEVEL && 
planetType === PlanetType.PLANET && 
(!planet || !planet.isInContract) 

As you can see the birth point planet needs to meet several conditions, first of all the planet's Perlin value needs to be within a certain range, in addition the planet's radius from the center of the universe needs to be between the current universe radius and the inner universe radius (to protect new players from entering the inner circle), Dark Forest will calculate the map while searching for a planet that meets the requirements, and after finding it, set it as the player's HomePlant.

From the above code, the player's birth point cannot be freely specified, but Dark Forest's code leaves an interface.

/* when setting up a new account in development mode, you can tell the game where to start searching for planets using this query string parameter. for example: */
// 
// ?searchCenter=2866,5627 
// 
const params = new URLSearchParams(window.location.search); 
if (params.has('searchCenter')) { 
    const parts = params.get('searchCenter')?.split(','); 
    if (parts) { 
        x = parseInt(parts[0], 10); 
        y = parseInt(parts[1], 10); 
        } 
}

Which means the player can specify a coordinate value, then Dark Forest searching from the specified coordinate value for HomePlant that meets the requirements, this is the method of specifying the birth point ~ it is not yet known whether this part of the code will be removed in the new version.

3、Thoughts on birth points and maps

As Dark Forest proceeds to V0.6R4, slowly everyone has more thoughts on Dark Forest's game mode. Generally speaking, Dark Forest's game time is about a week, and the recent round of Lightning war has shortened the time to 4 days. But overall each round of game time is still longer than the usual sense of competitive games, and as a MMO the game time is too short, if only to maintain the current state, as a phased competitive games is also feasible, but always feel the lack of something.

The subsequent development of the game mode is only in two directions, the first is to become a competitive game, modify the game parameters, making the confrontation stronger, faster pace of the game. But this will create several problems:

  • There are already very mature competitive games, Dark Forest's game mode has some innovation, but that's all, it can't play the unique charm of Dark Forest
  • As a competitive game, the number of participants in the game will not be too large, otherwise it will not be possible to select players and hold competitions in different tiers
  • Dark Forest's map is too random, it is difficult to build a more fair competitive environment

The second direction is to build Dark Forest into a multiplayer strategy game on a chain with a more ambitious environment, richer content, and longer period, with fierce battles and undisturbed free development, endless exploration of the universe and planets, dangerous expeditions, treasure hunters in the universe, prosperous cosmic cities, and hidden and unknown secret organizations and bases.

The current map and universe of Dark Forest is two-dimensional, as if flattened by two-way foil, narrow and suffocating. According to the current density of planets, there are 280,000 planets among the universe with a radius of 30,000, but excluding the low-level planets, there are not many areas available for development, which will soon be filled after a period of time. Although the area of the universe can be increased by expanding the radius, it is still very limited and the flat universe is very inconvenient to move around. The bigger problem is that with the current calculating power, a GPU can reveal map with millions of Hash, the universe will soon become secret-free and lose the biggest charm of Dark Forest.

What if we increase the map of Dark Forest by one dimension, the planet coordinates are composed of (x,y,z), z indicates the vertical coordinates, other mechanisms do not need to be changed, we will have a broader universe, the probability of a planet appearing in a single coordinate in the universe is one in 10,000, in the case of ensuring that there are not too many planets overlapping when the two-dimensional overlay is displayed, the z-directional stratification can With a radius of 30,000, there will be 2.8 billion planets, and a radius of 200,000, there will be 125.6 billion planets, which is almost the same as the number of planets in the Milky Way, and makes it impossible to explore the entire universe through Hash calculations. Since Dark Forest does not store all the planets in the universe on the chain at the beginning of the game, only those occupied planets will produce data on the chain, while other planets seem to be non-existent, quietly waiting for explorers to discover, and will only appear on the chain when they go there, so the data storage on the chain will not change much compared to now.

Thinking back to the moment when we first entered Dark Forest, what was the most attractive thing? Wasn't it unraveling the universe step by step, discovering a high-level planet, and planning the growing of your empire step by step?

In this wider universe, with more feasibility, the union can delineate the scope of their development, can designate arenas in the universe, can provide space for future artifacts, construction, there are too many things to conceive.

Egg: The article cover picture is the work of @alanw_luo, which is also the prototype of the artifacts in Dark Forest.

By: EliteMetaverse.eth

Subscribe to EliteMetaverse
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.