> For the complete documentation index, see [llms.txt](https://arena.v2.tothemoon.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arena.v2.tothemoon.net/deeper-mechanics-strategy-math-and-logic.md).

# Deeper Mechanics: Strategy, Math, and Logic

Beyond the elemental affinities, stances, and the strategic use of items lies a complex web of mechanics governing the New Arena. This depth ensures that every duel and battle is not just a test of raw power but a chess match requiring foresight, adaptability, and a keen understanding of underlying mathematics and logic.

### **The Shift to Elimination Format**&#x20;

We're evolving our competitive structure, moving away from traditional dueling to introduce an innovative Elimination format. Previously, our arenas were restricted to participant numbers that fit a power of two, limiting the diversity and size of our events. The new format allows for more flexibility, accommodating any number of fighters, whether it's 12, 24, or 50.

### How Elimination Works

In the Elimination format, each fighter is paired for combat twice per match, offering ample opportunity to score and progress. After each match, a certain percentage of fighters are eliminated, sharpening the competition until only one champion remains. This cycle of combat is simulated in real-time, ensuring each round is dynamic and engaging. With this new format, we aim to provide a more inclusive and thrilling competitive experience for all participants.

### Understanding the Combat Logic

At the heart of the New Arena's combat system is a series of calculations that determine the outcomes of each action. These calculations take into account a fighter's stamina, the effects of their chosen element and stance, and the strategic deployment of items. Here, we delve into the mathematical principles and logic that drive these crucial moments of combat.

**Stamina and Its Impact on Combat**

Stamina plays a pivotal role in a fighter's ability to execute and withstand attacks. The calculation for an attack's success or failure is influenced by the stamina differential between the attacker and their opponent:

* **Basic Stamina Impact:** When the stamina differential exceeds 50%, attackers face a 70% increased chance of missing. This pivotal mechanic compels fighters to weigh the risk of attacking against the potential benefit of conserving energy through defensive actions.
* **Stamina Synergy:** Engaging in combat affects stamina: delivering a hit consumes 15%, while a critical hit takes 20%. Conversely, if an opponent's attack misses or is dodged, the fighter recovers 5% and 10% stamina, respectively, reinforcing the strategic interplay of offense and defense.
* **Recover Stamina:** Defensive moves not only mitigate damage but also aid in stamina recovery: Buffs restore 10%, Focus 20%, and Healing moves, which are limited in use, can replenish 30% stamina, highlighting the importance of strategic decision-making in prolonged engagements.

```javascript
if (fighter.stamina < 25) chanceToHit -= 50;
```

*<mark style="color:blue;">\*it is important to note that the user does not interact with the fights directly, each fighter calculates their decisions without external interference.</mark>*

**Elemental and Stance Modifiers**

The Arena's elemental and stance systems introduce additional layers of strategy through specific modifiers that affect combat outcomes:

* **Elemental Boosts:** Fighters wielding items that match their element receive a 25% boost to their elemental mechanics, enhancing their effectiveness in combat up to a 125% overdrive cap. For instance, a Metal-aligned fighter with a matching item could see a significant increase in critical hit chances.

```javascript
if (fighter.element === item.element) elementalBoost += 25;
```

* **Stance Effects:** Each stance—Agility, Defense, Attack, and Endurance—alters a fighter's combat capabilities, from increasing dodge chances (Agility) to improving damage recovery (Endurance).

```javascript
switch(fighter.stance) {
    case Stances.AGILITY: dodgeChance += 20; break;
    case Stances.DEFENSE: blockChance += 20; break;
    case Stances.ATTACK: attackBias += 20; break;
    case Stances.ENDURANCE: blockBias += 20; break;
}
```

**Attack Outcome Calculations**

The culmination of these factors is most visible in the attack outcome calculations, where the chance of hitting, blocking, or dodging an attack is determined:

* **Calculating Hit Chance:** The base chance to hit is modified by the stamina difference, elemental and stance bonuses, and any relevant item effects.

```javascript
let chanceToHit = baseChance + staminaDiff + elementalBoost + stanceModifier;
```

* **Determining Critical Hits:** The chance of a critical hit is influenced by the fighter's focus and any elemental alignment with Metal or Dark, further modified by items in play.

```javascript
if (getChance(baseCritChance + focusBonus + elementalCritBoost)) {
    if(Fighter.Dark && !Opponent.Light) crit += 1
    if(Fighter.Light && Opponent.Dark) crit += 1.4

    if(Fighter.Earth) crit -= 0.6;
    if(Fighter.Metal) crit += 0.6;
    
    if(Opponent.Buffed) crit -=1
    if(Opponent.Focused) crit -= 0.5
}
```

### **Dynamic Battle Flow**

The arena battles are a masterclass in strategic adaptation, requiring fighters to continuously evolve their tactics in response to the unfolding dynamics of each round. Success hinges on a delicate balance of offensive and defensive maneuvers, informed by real-time assessments of stamina levels, the strategic deployment of elemental powers and stances, and the judicious use of items to gain a competitive edge. In this ever-changing battlefield, only those who can skillfully navigate these complex variables will emerge victorious.
