CaptainZ

CaptainZ

Prompt Engineer. Focusing on AI, ZKP and Onchain Game. 每周一篇严肃/深度长文。专注于AI,零知识证明,全链游戏,还有心理学。
twitter

The original text is already in English.

Dark Forest is a decentralized strategy game based on the Ethereum blockchain. Players can gather resources, build bases, develop technology, collect weapons, and engage in battles with other players to compete for resources.

In Dark Forest, each player controls their own planet and needs to gather resources, build bases, and develop technology to enhance their combat abilities. Players can use resources to construct buildings, research technology, and manufacture weapons in order to gain an advantage in battles.

When players are flying in interstellar space, they need to continuously scout and explore to discover other planets and resources. When two players simultaneously discover the same planet, they can choose to attack the planet or flee. During an attack, players need to use their weapons to attack the opponent's base and seize their resources.

The unique feature of Dark Forest is that the game is entirely based on blockchain technology, with each player's planets and resources stored on the blockchain and unable to be tampered with or deleted. Additionally, Dark Forest is a decentralized game (DeGame) without a central server controlling the game process, but rather maintained and decided upon by all players collectively.

Dark Forest is also the first game in the fully decentralized gaming industry to introduce a fog of war system, which has been recognized by Vitalik Buterin. In this article, we will delve into how such a real-time strategy game is implemented in a fully blockchain environment. @DfArchon will occasionally host "Community Rounds," and interested students can also participate in testing.

Let's start with the game types and compare MMORPG and MMORTS games:

  • MMO-RPG games: Massively multiplayer online role-playing games with open worlds and no end to the game. The fun of the game lies in experiencing the immersive story and the game universe. For example, World of Warcraft.

  • MMO-RTS games: Massively multiplayer online real-time strategy games with relatively small closed worlds. Each game round has a beginning and an end. The fun of the game lies in multiplayer confrontations within the story background, where players need to use strategies to obtain resources, develop, and eliminate enemies. Typical examples are StarCraft and Warcraft, with each round lasting 20-40 minutes.

  • DF is an MMORTS game because it allows a large number of simultaneous participants (up to thousands of players). Due to the limitations of blockchain TPS, each round lasts about 10 days, and the victory or defeat is determined by the ranking based on ladder scores. The scores mainly come from the resources obtained in the game (freely obtained through PVE and plundered through PVP). During the game pause, users cannot interact with the game contract.

Real Trading Operations

Initially, only the official rounds organized by the developers required invitation codes (keys) to participate. Now, with the lobby feature, anyone can create their own round, leading to the so-called community rounds (similar to community-organized competitions). Visit the homepage https://zkga.me/ and click "Create Lobby" to enter the lobby settings page.

Game settings: Modify the energy/silver coin recovery rate and sailing speed to adjust the game speed.

World Size: Change the map size by modifying the universe radius.

Space Type & Biome: Choose the game map.

Planets: Set the basic parameters of planets.

Player spawn: Generate player parameters.

Space junk: Set parameters for this game item.

Capture zones: Set parameters for occupation zones.

Artifacts: Set parameters for this game item.

Admin permissions: Set whether to allow whitelist players.

Advanced Snarks: Set parameters for the fog of war.

For more tips on using the lobby, please refer to this official answer: https://blog.zkga.me/introducing-dark-forest-lobbies

Dark Forest may seem complex on the surface, but its basic game rules are simple: planets have energy values that decay with distance. Jumping between planets is an attack on each other, and the outcome of the attack is determined by the size of the decayed energy value. There are already many articles and videos explaining how to play the game in more detail, so we won't go into further detail here.

Developer Documentation Analysis

https://dev-guides.zkga.me/

The developer documentation provides framework explanations for the game's development architecture, including plugin development, web client development, game contract development, and ZK circuit development.

Connect to the Blockchain

The game runs on the xDai layer2, which is the current Gnosis Chain. As the game requires extensive interaction with contracts during gameplay, it has built-in RPC nodes. The Gnosis team has even opened a dedicated node for this game.

Plugins

Dark Forest allows players to customize the default web client through a plugin system. Plugins are code snippets that players can write to generate alternative views of game data, automate common game processes, and even redesign game skins. Essentially, Dark Forest allows players to interact with the web client in any way they like through programming.

Mining

The key mechanism of Dark Forest is its cryptographic fog of war. When joining the game for the first time, players do not know the locations of other players. Players must calculate hash values to discover points of interest in the universe, such as planets and the positions of other players. These hash values are stored in the browser's local storage and treated as secret data. By default, the Dark Forest web client uses single-threaded JavaScript mining to explore the universe, but there are various measures players can take to increase the hash rate, such as changing the CPU core next to the mining button. If you try to set the number of cores to more than the actual number of cores on your computer, your mining performance will level off.

When a player's miner discovers a region of the universe, the web client saves the information related to these undiscovered regions to the browser's local storage. Dark Forest saves the data to IndexedDB. Players can also run a remote server to act as a miner for exploring the location map.

Snarking

Dark Forest is supported by ZK-Snark technology, which is a cryptographic technology used to prove the correctness of a function without revealing the function's input or logic. Dark Forest uses this technology to verify the validity of movements in the game without revealing the positions of planets to on-chain observers. This technology (Zk-snark Proof Generation) is computationally expensive! Therefore, the ZK-Proof computation is moved outside the browser and requires running a Node.JS locally. Of course, the game also allows using a remote server to run this service.

In summary, as a highly innovative blockchain game, Dark Forest's development has been relatively slow. One possible reason is that it is a community-driven project, which ensures decentralization but also affects development efficiency. The last official round was in February 2022. The web client was last updated in October 2020, while third-party (community) plugins have been slightly more active, including the nightmarket (anonymous trading of planet coordinates) in July 2022 and the lobby in March 2022.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.