> For the complete documentation index, see [llms.txt](https://topgambling.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://topgambling.gitbook.io/docs/game-guides/plinko.md).

# Plinko

## **Drop the Ball and Watch the Wins Roll In!**

Plinko is one of the most exciting and unpredictable games at **TopGambling**. Inspired by the classic game show, this game combines simplicity with thrilling potential for big payouts. This guide will help you understand the rules, strategies, and features of Plinko so you can make the most of your experience.

{% hint style="info" %}
RTP: 99% on all levels
{% endhint %}

{% hint style="info" %}
Max Multiplier: 1.000.000x
{% endhint %}

***

## **What is Plinko?**

Plinko is a game where a ball is dropped from the top of a pyramid-shaped grid. The ball bounces off pegs as it descends, landing in a slot at the bottom with a corresponding payout multiplier.

> **Objective**: Drop the ball and aim for high-value multipliers for big winnings!

<figure><img src="/files/WlReL7tWBdyNbsMJ5tWY" alt=""><figcaption></figcaption></figure>

***

## **Features of Plinko**

* **Adjustable Rows and Risk Levels**
  * Customize the gameplay to suit your style, whether you prefer low-risk consistency or high-risk excitement.
* **Multipliers**
  * Multiplier values vary based on the selected risk level and number of rows.
* **Fairness**
  * Plinko uses a **provably fair system**, ensuring every drop is random and unbiased.

***

## **Tips for Playing Plinko**

1. **Start with Low Risk**
   * If you’re new to the game, start with low risk to familiarize yourself with the mechanics.
2. **Experiment with Rows**
   * More rows mean more unpredictability but also higher rewards. Try different configurations to find your sweet spot.
3. **Set a Budget**
   * Decide on a betting limit before playing to manage your bankroll effectively.

***

## **Understanding Pascal’s Triangle**

Pascal’s Triangle is a triangular array of numbers, where each number is the sum of the two directly above it. It’s often used to calculate probabilities and plays a role in the design of Plinko boards.

### **How Pascal’s Triangle Works**

* The triangle starts with a single `1` at the top (row 0).
* Each subsequent row begins and ends with `1`.
* The numbers in between are calculated as the sum of the two numbers directly above them.

### **Formula to Calculate Pascal’s Triangle**

The value at position `(n, k)` in Pascal’s Triangle is given by:

![](/files/tYBC8wFclmsSoJtoz66J)​

Where:

* n is the row number (starting from 0).
* k is the position in the row (starting from 0).
* n! represents the factorial of nnn (e.g. 5! =5⋅4⋅3⋅2⋅1).

This formula corresponds to the number of ways a ball can reach a specific slot in the Plinko board.

<figure><img src="/files/mAv2LDcXEdDFz5sZsP01" alt=""><figcaption></figcaption></figure>

***

## **JavaScript Code for Pascal’s Triangle**

Here’s a JavaScript implementation to generate Pascal’s Triangle and visualize how Plinko outcomes relate to it:

```javascript
// Function to calculate Pascal's Triangle up to a given number of rows
function generatePascalsTriangle(rows) {
  const triangle = [];
  
  for (let n = 0; n < rows; n++) {
    triangle[n] = [];
    for (let k = 0; k <= n; k++) {
      // Using the formula: P(n, k) = n! / (k! * (n - k)!)
      triangle[n][k] = factorial(n) / (factorial(k) * factorial(n - k));
    }
  }
  
  return triangle;
}

// Helper function to calculate factorial
function factorial(num) {
  if (num === 0 || num === 1) return 1;
  return num * factorial(num - 1);
}

// Example: Generate and print Pascal's Triangle for 8 rows
const rows = 8;
const pascalsTriangle = generatePascalsTriangle(rows);

console.log("Pascal's Triangle:");
pascalsTriangle.forEach(row => console.log(row));

```

***

## **Calculation of Result**

When running the previous code with a triangle of 9 rows the results generated are these

<mark style="color:red;">\[1, 8, 28, 56, 70, 56, 28, 8, 1]</mark>

They represent the probabilities for a ball to fall in that specific slot, in other words:\
1+8+28+56+70+56+28+8+1 = 256 total probabilities

so in order to create a result for Plinko we can simply have to generate a random number with maximum value of 256 and then find the actual slot that has been selected with the random

```javascript
// Function to simulate the ball falling based on Pascal's Triangle (for row 8)
function GenerateResultIndexPlinko() {
  const rows = 9; // example of triangle provided
  const triangle = generatePascalsTriangle(rows);
  
  // Get the values from the last row
  const row = triangle[triangle.length-1];
  
  // Sum all values in row to create a "total sum"
  const totalSum = row.reduce((sum, value) => sum + value, 0);
  
  // Generate a random number between 0 and the total sum
  const randomValue = Math.floor(Math.random() * totalSum);
  
  // Now, find which index the random number falls into
  let cumulativeSum = 0;
  for (let i = 0; i < row.length; i++) {
    cumulativeSum += row[i];
    if (randomValue < cumulativeSum) {
      return i; // The index the ball lands in
    }
  }
}
```

this code returns the index of the values of pascals triangle, all that's left is to retrieve the multiplier associated to that slot and multiply it by bet amount.

{% hint style="warning" %}
Attention! \
This is just an example code provided to make you understand how the game works.\
In a real application the scenario the code related to the RNG number generated is very different.\
\
Matter of fact that we have to ensure a Real and Fair random number has been generated using player's seed input and also we have to ensure that all the data generated is stored correctly on our databases, in order for the player to verify himself the Fairness of a game using the data that has been generated.
{% endhint %}
