This repository contains the code for the "Oracle," which is responsible for the fair distribution of in-game rewards, along with a demo application showcasing its functionality.
The Oracle and demo application are built on Node.js. Below are the steps to deploy the application on a local machine:
- Install the latest version of Node.js: https://nodejs.org/en/download
- Clone or download this repository
- Open the terminal and navigate to the root folder of the downloaded repository
- Run
npm install
in the terminal to install dependencies - Run
npm run dev
in the terminal to start the application - Open the application at: http://localhost:3000
Players should:
- be able to review the source code of the reward distribution mechanism
- have the opportunity to review all the rewards from the current and past cycles
- check the blocks they opened and verify that their actions were honestly recorded in the system
Developers should not:
- change the total reward amount
- influence how rewards are distributed among players
- know where the prizes are hidden
Regardless of the device running the mechanism, the results should be deterministic and independent of external influences, given the same sequence of actions.
Hidden From Developers
The mechanism must prevent developers from knowing where the prizes are located. Everything should depend solely on player actions. Each subsequent action should randomly change the reward distribution while ensuring reproducibility for identical sequences of actions.
The mechanism should be designed so that if all blocks are opened, all available rewards are distributed, and players should be able to verify this.
The mechanism should be able to demonstrate the operation of the current cycle, eliminating the possibility of cheating by other players.
Players should have the ability to review their actions and those of other players in a fair simulation to ensure that their rewards were distributed fairly.
To achieve these objectives, the Oracle algorithm was developed, following this workflow:
- The Oracle is explicitly initialized, and all available rewards are loaded into it.
- A hash is initialized using a starting seed, which ensures randomness in reward distribution.
- The player clicks on any block.
- The mechanism updates the hash by appending
dig <block-index>
oropen <block-index>
, depending on the player's action. - The updated hash is passed to the Oracle to calculate the reward.
- The calculated reward is granted to the player.
- The process returns to step 3.
Important
As seen in this workflow, each player action modifies the hash, which determines the next reward. Thus, even on the same Oracle, different field-opening sequences lead to different results.
The Oracle's code is located within the downloaded application in the libs/oracle/src
folder.
libs/oracle/src/oracle-instance.js
contains the prizes loaded into the Oracle.libs/oracle/src/oracle-utils.js
includes hash modification functions and Oracle queries for reward retrieval.libs/oracle/src/core/oracle.js
contains the Oracle's implementation.libs/oracle/src/core/seed.js
handles hash generation and random number generation based on the hash.libs/oracle/src/test
contains functions for testing the Oracle and the random number generation mechanism, ensuring result reproducibility and Oracle functionality.public/history
stores the history of opened fields for the current and past cycles, allowing players to verify the algorithm's fairness.
Important
Importantly, we do not store the current cycle's seed in the history to prevent cheating attempts.
The demo application allows players to open a simulation of the current cycle to verify that all rewards indeed exist on the field and to confirm the fairness and reproducibility of the results.
One way to verify the consistency between the demo application and the real game is to take a screenshot of a chosen field and compare the results in the demo after the cycle ends. Players can also check all uncovered super prizes and prizes that were left unclaimed in that cycle.
Important
We do not disclose player data associated with block openings to maintain user anonymity.
src/controllers/field-controller.js
handles communication between the demo application and the Oracle, tracking opened fields, requesting new rewards, and implementing UI event handling.src/cycles
contains all initialization data for the Oracle for the current and past cycles.