# Banker AI

The **Banker AI** system is responsible for generating offers during the DealOrNoDeal game.

After each round of opened boxes, the Banker evaluates the remaining rewards and calculates an offer for the player. The player must decide whether to accept the deal or continue playing.

The behavior of the Banker is configurable through the `banker.yml` file.

***

### Configuration File

The Banker AI configuration is located in:

```
/plugins/DealOrNoDeal/banker.yml
```

This file controls how the Banker calculates offers, how risky the offers are, and when special offers such as box swaps may occur.

***

### Enabling or Disabling the Banker

The banker system can be enabled or disabled.

Example:

```yaml
banker:
  enabled: true
```

If the Banker AI is disabled, the plugin will not automatically generate offers.

Instead, administrators must manually send offers using commands.

Example commands:

```
/dond offer money <amount>
/dond offer item <material> <amount>
/dond offer swap
```

This allows server staff to control the banker offers manually during the game.

***

### Banker Personality

The Banker can operate in different behavior modes.

Example:

```yaml
personality: standard
```

Available personality modes:

| Mode           | Description                        |
| -------------- | ---------------------------------- |
| `conservative` | Produces safer and lower offers    |
| `standard`     | Balanced offer behavior            |
| `generous`     | Produces higher offers for players |

This setting controls the general style of banker offers.

***

### Offer Calculation

The Banker calculates offers based on the remaining rewards in the game.

Two main values are used:

* **Average reward value**
* **Median reward value**

Example configuration:

```yaml
average_weight: 0.55
median_weight: 0.45
```

Explanation:

| Setting          | Description                           |
| ---------------- | ------------------------------------- |
| `average_weight` | Influence of the average reward value |
| `median_weight`  | Influence of the median reward value  |

Increasing the average weight makes the banker more aggressive.

Increasing the median weight creates more stable offers.

***

### Randomness

The Banker can apply a small random multiplier to offers.

Example:

```yaml
randomness:
  enabled: true
  min: 0.92
  max: 1.05
```

Explanation:

| Setting | Description                                        |
| ------- | -------------------------------------------------- |
| `min`   | Minimum multiplier applied to the calculated offer |
| `max`   | Maximum multiplier applied to the calculated offer |

Randomness prevents the Banker from always making predictable offers.

***

### Round Multipliers

The Banker uses round multipliers to control how generous offers are during different stages of the game.

Example:

```yaml
round_multipliers:
  1: 0.30
  2: 0.38
  3: 0.46
  4: 0.55
  5: 0.65
  6: 0.78
  7: 0.90
```

Lower values in early rounds encourage players to continue playing.

Higher values in later rounds increase the attractiveness of banker offers.

***

### Risk Handling

The Banker adjusts offers depending on how risky the current board is.

Example:

```yaml
risk:
  threshold_1: 4.0
  threshold_2: 6.0
  modifier_1: 0.85
  modifier_2: 0.75
```

Explanation:

| Setting       | Description                             |
| ------------- | --------------------------------------- |
| `threshold_1` | First risk threshold                    |
| `threshold_2` | Second risk threshold                   |
| `modifier_1`  | Offer multiplier applied at threshold 1 |
| `modifier_2`  | Offer multiplier applied at threshold 2 |

If very large rewards remain on the board, the Banker may reduce the offer to avoid excessive payouts.

***

### Swap Offers

In some situations, the Banker may offer the player a **box swap** instead of money.

Example:

```yaml
swap:
  enabled: true
  chance_4_boxes: 0.18
  chance_3_boxes: 0.40
  final_2_boxes: true
```

Explanation:

| Setting          | Description                                |
| ---------------- | ------------------------------------------ |
| `enabled`        | Enables or disables swap offers            |
| `chance_4_boxes` | Chance of a swap offer when 4 boxes remain |
| `chance_3_boxes` | Chance of a swap offer when 3 boxes remain |
| `final_2_boxes`  | Always offer a swap when 2 boxes remain    |

Swap offers introduce additional strategic decisions for players.

***

### How Banker Offers Influence Gameplay

The banker system plays a major role in shaping the gameplay experience.

Factors that influence banker offers include:

* remaining rewards on the board
* current game round
* risk level of the board
* configured personality
* random variation

These systems ensure that banker offers remain dynamic and unpredictable.
