Breakpoints & ab
This commit is contained in:
parent
6d9b0b5a17
commit
8f88fdb121
|
|
@ -0,0 +1,116 @@
|
|||
// Exact probabilistic armor-destruction model for generated weapons.
|
||||
#import "weapon_metrics.typ": *
|
||||
#import "weapon_breakpoints.typ": comparison-dice-pools, mean, numeric-median
|
||||
|
||||
#let analyzed-protections = range(5, 16)
|
||||
|
||||
#let armor-destroyed(damage, protection, armor-break) = (
|
||||
calc.min(armor-break, calc.max(0, damage - protection))
|
||||
)
|
||||
|
||||
#let expected-attack-armor-destruction(item, dice, protection) = {
|
||||
let probability = item.success-probability
|
||||
range(0, dice + 1).map(successes => {
|
||||
let damage = damage-at-successes(
|
||||
item.base-damage,
|
||||
item.p-damage,
|
||||
calc.min(successes, item.rmax),
|
||||
)
|
||||
(
|
||||
binomial-probability(dice, successes, probability)
|
||||
* armor-destroyed(damage, protection, item.armor-break)
|
||||
)
|
||||
}).sum()
|
||||
}
|
||||
|
||||
#let armor-commitment-analysis(item, dice, protection) = {
|
||||
let single = expected-attack-armor-destruction(item, dice, protection)
|
||||
let candidates = if item.actions == 1 and dice >= 2 {
|
||||
range(1, calc.floor(dice / 2) + 1).map(first => (
|
||||
first: first,
|
||||
second: dice - first,
|
||||
destruction: expected-attack-armor-destruction(item, first, protection)
|
||||
+ expected-attack-armor-destruction(item, dice - first, protection),
|
||||
))
|
||||
} else {
|
||||
()
|
||||
}
|
||||
let best-split = if candidates.len() == 0 { none } else {
|
||||
candidates.sorted(key: candidate => -candidate.destruction).first()
|
||||
}
|
||||
let use-split = best-split != none and best-split.destruction > single
|
||||
(
|
||||
destruction: if use-split { best-split.destruction } else { single },
|
||||
attacks: if use-split { 2 } else { 1 },
|
||||
strategy: if use-split {
|
||||
str(best-split.first) + "+" + str(best-split.second)
|
||||
} else {
|
||||
str(dice)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#let armor-destruction-grid(dice) = all-weapon-metrics.map(item => (
|
||||
analyzed-protections.map(protection => (
|
||||
armor-commitment-analysis(item, dice, protection).destruction
|
||||
))
|
||||
))
|
||||
|
||||
#let armor-utilization-grid(dice) = all-weapon-metrics.map(item => (
|
||||
analyzed-protections.map(protection => {
|
||||
let result = armor-commitment-analysis(item, dice, protection)
|
||||
let capacity = item.armor-break * result.attacks
|
||||
if capacity == 0 { 0 } else { result.destruction / capacity * 100 }
|
||||
})
|
||||
))
|
||||
|
||||
#let armor-protection-breakpoint(item, dice) = {
|
||||
if item.armor-break == 0 { return none }
|
||||
let values = analyzed-protections.map(protection => (
|
||||
armor-commitment-analysis(item, dice, protection).destruction
|
||||
))
|
||||
let drops = range(1, analyzed-protections.len()).map(index => (
|
||||
protection: analyzed-protections.at(index),
|
||||
drop: values.at(index - 1) - values.at(index),
|
||||
))
|
||||
let strongest = drops.sorted(key: point => -point.drop).first()
|
||||
if strongest.drop <= 0.000001 { none } else { strongest }
|
||||
}
|
||||
|
||||
#let armor-breakpoint-table = all-weapon-metrics.map(item => (
|
||||
weapon: item.name,
|
||||
points: comparison-dice-pools.map(dice => armor-protection-breakpoint(item, dice)),
|
||||
))
|
||||
|
||||
#let armor-summary = comparison-dice-pools.map(dice => {
|
||||
let at(protection) = mean(all-weapon-metrics.map(item => (
|
||||
armor-commitment-analysis(item, dice, protection).destruction
|
||||
)))
|
||||
let utilization = mean(all-weapon-metrics.filter(item => (
|
||||
item.armor-break > 0
|
||||
)).map(item => {
|
||||
let result = armor-commitment-analysis(item, dice, 10)
|
||||
result.destruction / (item.armor-break * result.attacks) * 100
|
||||
}))
|
||||
let valid-breakpoints = all-weapon-metrics.map(item => (
|
||||
armor-protection-breakpoint(item, dice)
|
||||
)).filter(point => point != none)
|
||||
(
|
||||
dice: dice,
|
||||
protection-5: at(5),
|
||||
protection-10: at(10),
|
||||
protection-15: at(15),
|
||||
utilization-10: utilization,
|
||||
median-breakpoint: numeric-median(valid-breakpoints.map(point => point.protection)),
|
||||
)
|
||||
})
|
||||
|
||||
#let nature-armor-series(dice) = weapon-natures.map(nature => (
|
||||
name: weapon-nature-labels.at(nature),
|
||||
points: analyzed-protections.map(protection => (
|
||||
protection,
|
||||
mean(all-weapon-metrics.filter(item => item.nature-key == nature).map(item => (
|
||||
armor-commitment-analysis(item, dice, protection).destruction
|
||||
))),
|
||||
)),
|
||||
))
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
// Report views for exact armor-destruction expectations and breakpoints.
|
||||
#import "@preview/primaviz:0.6.0": heatmap, multi-scatter-plot
|
||||
#import "weapon_armor_breakpoints.typ": *
|
||||
#import "report_style.typ": chart-theme, rounded
|
||||
#import "../theme/tables.typ" as tables
|
||||
#import "../theme/themes.typ": make-theme
|
||||
|
||||
#let report-theme = make-theme(theme-name: "steingrund")
|
||||
#let armor-palette = (
|
||||
report-theme.at("chart-4"),
|
||||
report-theme.at("chart-3"),
|
||||
report-theme.at("chart-2"),
|
||||
report-theme.at("parchment-light"),
|
||||
)
|
||||
#let shape-short = (
|
||||
"Griffes": "Grif.", "Hast": "Hast", "Épée": "Épée",
|
||||
"Marteau": "Mart.", "Hache": "Hache", "Arbalète": "Arba.", "Arc": "Arc",
|
||||
)
|
||||
#let nature-short = (Light: "L", Medium: "M", Heavy: "Ld", SuperHeavy: "SL")
|
||||
#let weapon-labels = all-weapon-metrics.map(item => [
|
||||
#shape-short.at(item.shape) · #nature-short.at(item.nature-key)
|
||||
])
|
||||
|
||||
#let weapon-armor-report() = {
|
||||
pagebreak()
|
||||
heading(level: 3)[Franchissement et destruction d’armure]
|
||||
[Une attaque qui inflige $D$ dégâts contre une protection $P$ détruit
|
||||
`min(Brise-armure, max(0, D − P))` points d’armure. Les résultats ci-dessous
|
||||
intègrent toute la distribution binomiale. Les armes à 1A testent tous les
|
||||
partages légaux sur 2A et retiennent celui qui maximise la destruction; la
|
||||
protection reste un seuil de référence constant entre les deux attaques.]
|
||||
|
||||
let summary-rows = armor-summary.map(row => (
|
||||
str(row.dice),
|
||||
rounded(row.at("protection-5"), digits: 2),
|
||||
rounded(row.at("protection-10"), digits: 2),
|
||||
rounded(row.at("protection-15"), digits: 2),
|
||||
rounded(row.at("utilization-10"), digits: 1) + [%],
|
||||
rounded(row.at("median-breakpoint"), digits: 1),
|
||||
))
|
||||
tables.set-table-style(
|
||||
table(
|
||||
columns: (0.55fr, 0.9fr, 0.9fr, 0.9fr, 1.15fr, 1.15fr),
|
||||
align: (right,) * 6,
|
||||
table.header(
|
||||
[Pool], [Armure détr. P5], [P10], [P15], [Capacité à P10],
|
||||
[Rupture médiane],
|
||||
),
|
||||
..summary-rows.flatten(),
|
||||
),
|
||||
table-theme: "steingrund",
|
||||
text-size: 7.5pt,
|
||||
)
|
||||
|
||||
let first = armor-summary.first()
|
||||
let last = armor-summary.last()
|
||||
let evolution(start, end) = if start == 0 { 0 } else { (end / start - 1) * 100 }
|
||||
[*Conclusion calculée.* Entre #first.dice et #last.dice dés, la destruction
|
||||
moyenne contre P10 passe de #rounded(first.at("protection-10"), digits: 2) à
|
||||
#rounded(last.at("protection-10"), digits: 2)
|
||||
(#rounded(evolution(first.at("protection-10"), last.at("protection-10")), digits: 1)%).
|
||||
La rupture médiane se déplace de P#rounded(first.at("median-breakpoint"), digits: 1)
|
||||
à P#rounded(last.at("median-breakpoint"), digits: 1).]
|
||||
|
||||
heading(level: 4)[Courbes de résistance par poids]
|
||||
grid(
|
||||
columns: (1fr, 1fr, 1fr),
|
||||
column-gutter: 8pt,
|
||||
..comparison-dice-pools.map(dice => multi-scatter-plot(
|
||||
(series: nature-armor-series(dice)),
|
||||
width: 100%,
|
||||
height: 180pt,
|
||||
title: [#dice dés],
|
||||
point-size: 4pt,
|
||||
x-label: [Protection],
|
||||
y-label: [Armure détruite],
|
||||
theme: chart-theme,
|
||||
)),
|
||||
)
|
||||
|
||||
heading(level: 4)[Destruction attendue par arme]
|
||||
for dice in comparison-dice-pools {
|
||||
block(breakable: false)[
|
||||
#heading(level: 5)[#dice dés]
|
||||
#align(center, heatmap(
|
||||
(
|
||||
rows: weapon-labels,
|
||||
cols: analyzed-protections.map(value => [P#value]),
|
||||
values: armor-destruction-grid(dice),
|
||||
),
|
||||
cell-size: 17pt,
|
||||
show-values: true,
|
||||
palette: armor-palette,
|
||||
theme: chart-theme,
|
||||
))
|
||||
]
|
||||
}
|
||||
|
||||
heading(level: 4)[Rendement de la capacité de brise-armure]
|
||||
[Cette carte normalise la destruction attendue par la capacité maximale de
|
||||
brise-armure disponible sur les attaques retenues. Elle distingue une grande
|
||||
statistique théorique d’une statistique effectivement exploitable.]
|
||||
block(breakable: false)[
|
||||
#heading(level: 5)[Utilisation à 8 dés (%) ]
|
||||
#align(center, heatmap(
|
||||
(
|
||||
rows: weapon-labels,
|
||||
cols: analyzed-protections.map(value => [P#value]),
|
||||
values: armor-utilization-grid(8),
|
||||
),
|
||||
cell-size: 17pt,
|
||||
show-values: true,
|
||||
palette: armor-palette,
|
||||
theme: chart-theme,
|
||||
))
|
||||
]
|
||||
|
||||
heading(level: 4)[Points de rupture par arme]
|
||||
[La rupture est le passage de protection qui provoque la plus forte perte
|
||||
marginale de destruction attendue; aucun seuil de pourcentage n’est imposé.]
|
||||
let breakpoint-rows = armor-breakpoint-table.map(row => (
|
||||
row.weapon,
|
||||
..row.points.map(point => (
|
||||
if point == none { [Inopérant] } else {
|
||||
[P#point.protection · −#rounded(point.drop, digits: 2)]
|
||||
},
|
||||
)),
|
||||
))
|
||||
tables.set-table-style(
|
||||
table(
|
||||
columns: (1.45fr, 1fr, 1fr, 1fr),
|
||||
align: (left, right, right, right),
|
||||
table.header([Arme], [5 dés], [8 dés], [14 dés]),
|
||||
..breakpoint-rows.flatten(),
|
||||
),
|
||||
table-theme: "steingrund",
|
||||
text-size: 7.2pt,
|
||||
)
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#import "@preview/primaviz:0.6.0": grouped-bar-chart, grouped-stacked-bar-chart, horizontal-bar-chart
|
||||
#import "weapon_metrics.typ": *
|
||||
#import "weapon_breakpoint_report.typ": weapon-breakpoint-report
|
||||
#import "weapon_armor_report.typ": weapon-armor-report
|
||||
#import "report_style.typ": chart-theme, metric-card, rounded
|
||||
#import "../theme/tables.typ" as tables
|
||||
|
||||
|
|
@ -208,4 +209,5 @@
|
|||
)
|
||||
|
||||
weapon-breakpoint-report()
|
||||
weapon-armor-report()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue