Family, get on the car first, and then study!👇

Chinese communication of CZ-DegenReborn rebirth

My Twitter

reborn__cz


<aside> 📌 In the past few days, the official white paper has updated some new explanations about Jackpot, and the content is not much. Mainly, it talks about the question of "how to randomly select 10 characters in HoF?" This time, Jackpot will be briefly introduced and reviewed in the form of FAQs.

</aside>

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/6e872b71-19ab-43c6-9563-04cf5ab6637c/screenshot-degenreborn.gitbook.io-2023.03.13-14_27_52.png

Officially updated page: https://degenreborn.gitbook.io/litepaper/airdrop-and-jackpot-summary


❓What are Airdrop and Jackpot❓

All the funds from the game protocol's revenue and user entry will go into the Jackpot, forming a prize pool. Then the money in the pool is used as a game reward for players, including Airdrop.

Refer to the 1️⃣st article for specific game rules.

❓What is HoF❓

The top 100 players in the game

❓What are the two pieces of code updated on the official website❓

These two pieces of code refer to the same thing, but express it in two languages, that is, "how are 10 random characters selected in HoF?"

//Taking the JavaScript given on the official website as an example, this code implements a random lottery function getRaffleWinners
//The function accepts four parameters: the candidate array candidates, the weight array weights, the number of winners numWinners, and a random seed seed
//The function logic is roughly: the function generates a weighted candidate array based on the weight and candidate, and then generates a random number using the given random seed to select the winner from the weighted candidate array. If the elements in the weighted candidate array are not enough to meet the number of winners, all elements in the weighted candidate array are returned.

const seedrandom = require('seedrandom');

function getRaffleWinners(candidates, weights, numWinners, seed) {
  const rng = seedrandom(seed);
  const weightedCandidates = candidates.flatMap((c, i) => Array.from({ length: weights[i] }).fill(c));
  const winners = [];
  while (winners.length < numWinners && weightedCandidates.length > 0) {
    const randomIndex = Math.floor(rng() * weightedCandidates.length);
    winners.push(weightedCandidates.splice(randomIndex, 1)[0]);
  }
  return winners;
}

const candidates = Array.from({ length: 100 }, (_, i) => `Candidate ${i + 1}`);
const weights = Array.from({ length: 100 }, () => Math.ceil(Math.random() * 10));
const numWinners = 10;
const seed = 'myRandomSeed';

const winners = getRaffleWinners(candidates, weights, numWinners, seed);
console.log('Winners:', winners);

This random selection process is implemented through the following steps:

1. Create a pseudo-random number generator object rng based on the input random seed seed.

2. Weight the candidates according to the corresponding weights to generate a weighted candidate array weightedCandidates.

3. Initialize an empty array winners for the winners.

4. Enter the loop until the length of winners is equal to the preset number of winners numWinners or the weighted candidate array weightedCandidates is empty.

5. Randomly select an element in the weighted candidate array weightedCandidates.

6. Remove the selected element from the weighted candidate array weightedCandidates and add it to the array winners.

7. Return the array winners.

Simply put, this random selection process is to randomly select several elements from the weighted candidate array as winners, and the probability of selection is proportional to the weight of the element. The randomness comes from the process of generating random numbers. By specifying the random seed, the generation process of random numbers can be controlled, thereby ensuring the repeatability of the random process.

As for these 10 random characters, it refers to these 3 places mentioned in my 1️⃣st article👇

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/76440538-b3ae-4d8e-9241-001a3a36026a/Untitled.png