The tech behind Nine Chronicles — Part 1

Have you ever wondered what happens in the background of Nine Chronicles whenever you press a button within the game client? Let’s explore!

As Nine Chronicles is a fully decentralized game that uses blockchain technology things happen a little differently from what happens in a traditional MMO. Some of these differences may cause some frustration with our players, but there are also advantages too. In previous blogs, we’ve outlined our belief in true ownership of items and the importance for preventing cheating.

In a new series of blogs we will take a deeper dive in the technology behind Nine Chronicles. Here we will look at combat, but in a follow-up piece we will look at the marketplace and crafting.

One of our previous blogs explains the virtues of the fully decentralized gaming paradigm. While that piece provided an overview of the fundamental ideas, this blog will dig deeper into the underlying technology. However, we will do our best not to get too technical. There won’t be any code or mathematics!

Actions become transactions

In the game client, once you have loaded your character, you will see the main game screen. This is the familiar screen where you can see the marketplace, the workshop, combat rankings, the entrance for elemental dungeons, and the portal to enter the different worlds (also called dungeons).

The graphical interface provides a nice way to interact with the data that sits on the Nine Chronicles blockchain. All game data sits on the chain which means a copy of this data is stored by all people who run the blockchain software.

One thing that happens here, but don’t see, is the data from the blockchain is parsed into a local database which holds the latest state of the Nine Chronicles gaming world. This is done to improve the performance of the game.

Combat transactions

From the main screen, whenever a player clicks on the portal they are led through a couple of screens that lets them choose which level they wish to fight in as well as choose their equipment. Finally, a player must press the “Start” button to proceed to combat.

The game client interprets this clicking action and turns it into a transaction ready to be sent to the blockchain. Each action has to be signed by a player’s private key. This way everyone knows who has performed which action. A private key is like a password and is unique to every account.

Transaction Broadcasting

This signed action (read: transaction) is prepared by the game client and sent to the blockchain node running on your computer, which in turn broadcasts your transaction across the Internet to all other computers who have joined the Nine Chronicles blockchain network.

This node software is managed by the game Launcher, which is the program you start when you press the Nine Chronicles icon on your computer. As all players run the Launcher before starting the game, all players are also running a blockchain node and helping to sustain the game. As mentioned above, anyone who runs the blockchain software stores the history of all transactions.

Energy Cost (“Prosperity” and “Action Power”)

Players start with 120 action power but use up this action power when entering combat.

Pressing the Start button has a cost of 5 energy (“action power”); however, this is not a financial cost to the player as energy naturally restores every 1700 blocks. Every single block, players rejuvenate 1 prosperity. After 1700 blocks, players have full prosperity and can refill their action power back to 120.

This energy mechanism is how we prevent players from spamming the network with too many actions at once. Players who send too many transactions will have their extra transactions ignored by the other players in the network.

Determining the battle result

The outcome of a battle follows a formula that depends on a player’s equipment stats plus an element of randomness. The source of this randomness is the block hash of the block where your transaction is included. As this happens in the future you won’t know the block hash that corresponds to your combat until that block is added to the chain.

As all data in a blockchain is public, then all players running the software know the stats of your player and will also see the block hash for combat too. This means that all players can calculate the result of your combat in a deterministic way once the random value is known. What’s also implied here is that all players calculate the combat results in the exact same way. This is how we prevent cheating in a decentralized game.

Transactions and blocks

When you send out your transaction across the network it will be included in a future block, but you won’t know which block until miners have had a chance to include the transaction within the blocks they create.

Once a miner creates a block, they broadcast it to all other computers within the network. If the block is valid then the other computer will accept this block as part of the chain. Due to the nature of the global scale of the Internet, these blocks cannot be transmitted instantly from one computer to another. There is always a chance that another miner will produce a competing block. As blocks within the chain must be sequential, there can’t ever be 2 blocks at the same position. This means that there is some period of time when a block is at risk of being removed from the chain, and the transactions inside being held until a new block is created. This is known as block reorganization, or “reorg” for short.

How to be sure that your combat result is completely lost? If your transaction is not included in a winning block then it is cached by miners to be included in another block. At some point your transaction will be inside a winning block such that you won’t have to fear a reorg. The point at which we can be sure is when enough blocks have been added on top of the block containing your transaction. In Bitcoin, it is suggested that users wait for 6 blocks to follow on. In Nine Chronicles, the game has a 3 block confirmation time.

Anti-Rollback protection

While 3 block confirmation times should be good enough, there is still a risk of a deep reorganization where multiple blocks become invalidated at once. This is a problem for a game as players don’t want to wait a long time in order to progress. Our solution to this problem is to use authorized miners. These are special mining nodes that were set at Genesis and provide a checkpoint of correctness every 50 blocks.

While this may not be the perfect, it does provide a practical solution to the problem. This is only a temporary solution until we rebuild our consensus engine to use Proof-of-Stake.

Advantages

Our network is peer-to-peer such that it should not be dependent on Planetarium and should run 24/7. In this early access phase of the game, we have faced a number of challenges such that we haven’t quite met this ideal. A number of improvements are constantly being made in order to improve the network’s stability and the player’s gaming experience.

The biggest advantage of decentralization is that no player can cheat the game rules. All players help to prevent cheating by running a Nine Chronicles blockchain node. This means all players check the actions of every other player.

Get in touch!

Email us at contact@planetariumhq.com or come say hello on our Discord channel!

About Planetarium

Planetarium is a blockchain company pioneering the ecosystem for community-powered online games. Planetarium’s technology equips developers with powerful tools to create fully decentralized, cross-platform blockchain games that can live forever on networks powered by the players. The team is developing Nine Chronicles, an open source, decentralized role-playing game that launched in October 2020. To learn more, please visit planetariumhq.com.

Nine Chronicles is a fully decentralized RPG powered by the players. https://nine-chronicles.com