Files
horse/zenno/src/routes/doc/fans/+page.svelte
T

239 lines
8.5 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script lang="ts">
import { resolve } from '$app/paths';
import CalcInfo from '../../race/CalcInfo.svelte';
import Article from '../Article.svelte';
import Sec from '../Sec.svelte';
import * as fans from './fans';
let winFans = $state(700);
let fanBonus = $state(0);
let finishOrder = $state(1);
let margin = $state(0);
let skills = $state(0);
let glowsticks = $state(false);
const baseFans = $derived(fans.baseFans(winFans, finishOrder));
const marginFans = $derived(fans.marginFans(baseFans, finishOrder, margin));
const skillFans = $derived(fans.skillFans(baseFans, skills));
const glowstickBonus = $derived(glowsticks ? 50 : 0);
const gainedFans = $derived(fans.gained(baseFans, marginFans, skillFans, fanBonus, glowstickBonus));
const marginType = $derived(finishOrder === 1 ? 'Win Margin' : 'Margin vs. Winner');
const orderPct = [
[1, 100],
[2, 40],
[3, 25],
[4, 15],
[5, 10],
[6, 9],
[7, 8],
[8, 7],
[9, 6],
[10, 5],
[11, 4],
[12, 3],
[13, 2.5],
[14, 2],
[15, 1.5],
[16, 1],
[17, 1],
[18, 1],
] as const;
const marginBonus = [
['Nose – 3/4 L', 0, 9],
['1 L – 2.5 L', 2, 6],
['3 L – 4 L', 4, 4],
['5 L – 6 L', 6, 2],
['7L – distance', 9, 0],
] as const;
const skillBonus = [
['0', 0],
['1-3', 2],
['4-6', 3],
['7-9', 5],
['10+', 8],
] as const;
</script>
<Article>
{#snippet head()}
<Sec h={1} id="top" class="text-center pointer-coarse:mb-8">Career Fan Gain Is Solved</Sec>
<p>
Thanks to work by @Moxayoru and @Werseter on the Hakuraku Discord, a precise formula for fans gained from career races has
been found.
</p>
<p>
There is no random component to fan gain, except insofar as the race itself is random. It is now known to be entirely
determined by five factors:
</p>
<ul class="mb-4 list-disc pl-4">
<li>Base fans, according to the race and finish placement.</li>
<li>Fan bonus from support cards.</li>
<li>Margin of the win, or margin behind the winner if the player's trainee did not win.</li>
<li>Number of skills the trainee activated during the race.</li>
<li>In Trackblazer/MANT, use of glowsticks.</li>
</ul>
<p>
The identified formula perfectly fits hundreds of recorded career races, including losses. These results have important
implications both for fan runs and for low fan bonus decks for which debut can fall short of fan requirements for early
career goals.
</p>
{/snippet}
<Sec h={2} id="calc-fans">Calculate Fans</Sec>
<p>
This tool will calculate your exact fan gain from a race. Use the fan value displayed in the race selection menu for the Race
Fans field.
</p>
<form class="mx-auto mb-4 grid grid-cols-1 gap-2 rounded-md p-4 text-center shadow-md ring md:max-w-2xl md:grid-cols-3">
<div>
<label for="calc-base-fans">Race Fans</label>
<input id="calc-base-fans" class="max-w-32" type="number" min="0" max="30000" step="100" bind:value={winFans} />
</div>
<div>
<label for="calc-fan-bonus">Fan Bonus</label>
<input id="calc-fan-bonus" class="max-w-32" type="number" min="0" max="150" step="5" bind:value={fanBonus} />
</div>
<div>
<label for="calc-finish-order">Finish Order</label>
<select id="calc-finish-order" class="max-w-32" bind:value={finishOrder}>
{#each orderPct as [v] (v)}
<option value={v}>{v}</option>
{/each}
</select>
</div>
<div>
<label for="calc-margin">{marginType} (L)</label>
<input id="calc-margin" class="max-w-32" type="number" min="0" step="0.25" bind:value={margin} />
</div>
<div>
<label for="calc-skills">Activated Skills</label>
<input id="calc-skills" class="max-w-32" type="number" min="0" step="1" bind:value={skills} />
</div>
<div class="my-auto">
<input id="calc-glowsticks" class="min-h-6 min-w-6 align-middle" type="checkbox" bind:checked={glowsticks} />
<label for="calc-glowsticks">Glowsticks</label>
</div>
</form>
<div class="mx-auto grid max-w-2xl grid-cols-1 md:grid-cols-3">
<CalcInfo title="Base Fans">{baseFans}</CalcInfo>
<CalcInfo title="Fans from Margin">{marginFans}</CalcInfo>
<CalcInfo title="Fans from Skills">{skillFans}</CalcInfo>
<CalcInfo title="Fans Gained" class="md:col-start-2">{gainedFans}</CalcInfo>
</div>
<Sec h={2} id="base-fans">Base Fans</Sec>
<p>
Base fans is a parameter per race and finish placement, defined in <a href={resolve('/doc/mdb')}>master data</a>. The number
shown in the career race selection menu is the base fans for first place. While it is defined separately for each race and
finish order, every race currently follows the same curve for all placements, up to rounding.
</p>
<table class="mx-auto mb-4 border text-center">
<thead>
<tr>
<th scope="col" class="px-2">Placement</th>
<th scope="col" class="px-2">Fan Ratio</th>
</tr>
</thead>
<tbody>
{#each orderPct as [o, p] (o)}
<tr class="even:bg-mist-300 dark:even:bg-mist-900">
<td>{o}</td>
<td>{p}%</td>
</tr>
{/each}
</tbody>
</table>
<Sec h={2} id="margin">Fans from Margin</Sec>
<p>When the trainee places in the top five, she receives a bonus percentage of base fans according to the finish margin.</p>
<p>
The bonus depends on whether the trainee won the race. If so, it is calculated by her margin versus second place. Otherwise,
her total margin behind the winner is used. If she did not place in the top five, then she gains no fans from margin.
</p>
<table class="mx-auto mb-4 border text-center">
<thead>
<tr>
<th scope="col" class="px-2">Actual<br />Margin Within</th>
<th scope="col" class="px-2">Bonus for Winner</th>
<th scope="col" class="px-2">Bonus for Podium</th>
</tr>
</thead>
<tbody>
{#each marginBonus as [m, w, l] (m)}
<tr class="even:bg-mist-300 dark:even:bg-mist-900">
<td>{m}</td>
<td>{w}%</td>
<td>{l}%</td>
</tr>
{/each}
</tbody>
</table>
<Sec h={2} id="skills">Fans from Skill Activations</Sec>
<p>The trainee receives a bonus percentage of base fans according to the number of skills she activated during the race.</p>
<table class="mx-auto mb-4 border text-center">
<thead>
<tr>
<th scope="col" class="px-2">Activated Skills</th>
<th scope="col" class="px-2">Bonus</th>
</tr>
</thead>
<tbody>
{#each skillBonus as [n, b] (n)}
<tr class="even:bg-mist-300 dark:even:bg-mist-900">
<td>{n}</td>
<td>{b}%</td>
</tr>
{/each}
</tbody>
</table>
<Sec h={2} id="rounding">Calculation Order and Rounding</Sec>
<p>The calculation is perfomed as if in the following order.</p>
<ol class="mb-4 list-decimal pl-4">
<li>Look up base fans for the race and placement. This value is always an integer.</li>
<li>Calculate fans from win margin as a proportion of base fans and round down.</li>
<li>Calculate fans from skill activation count as a proportion of base fans and round down.</li>
<li>Calculate the sum of base fans, win margin fans, and skill activation fans.</li>
<li>Apply fan bonus to the sum in single-precision floating point, without otherwise rounding.</li>
<li>
Round to five significant figures with halfway cases rounded up, then round down. Examples are useful here.
<ul class="list-[revert] pl-8">
<li>
700 base plus 14 from margin with 88% fan bonus = <span class="inline-block">714&times;1.88</span> = 1342.32, rounded to five
significant figures becomes 1342.3, rounded down to 1342.
</li>
<li>
10500 base plus 210 from margin with 105% fan bonus =
<span class="inline-block">10710&times;2.05</span>
= 21955.5, rounded to five significant figures becomes 21956, rounded down to 21956.
</li>
<li>
100 base fans plus 2 fans from skills with 88% fan bonus = <span class="inline-block">102&times;1.88</span> = 191.76, rounded
to five significant figures becomes 191.76, rounded down to 191.
</li>
</ul>
</li>
<li>(Trackblazer/MANT) If glowsticks were used for the race, apply their multiplier and round down.</li>
</ol>
<Sec h={2} id="data">Data</Sec>
<p>
The data for this research comes from 325 races and fan results dumped using <a
href="https://werseter.github.io/umadump/"
target="_blank"
rel="noopener noreferrer">Umadump</a
>. The races come from careers run between 19 Aug and 18 Oct 2026. These careers include fan bonus values of 50, 55, 65, 70,
80, 88, and 105. The identified formula predicts the actual fan gain perfectly for all of the races. You can
<a
href="https://docs.google.com/spreadsheets/d/1_jtOv6qk9dP4jJTagJqG53Pvj48IVd6gl2zKpyT6Kvs/edit?gid=463816108#gid=463816108"
target="_blank"
rel="noopener noreferrer">view the data</a
>.
</p>
</Article>