Skip to content

Commit

Permalink
Merge pull request #1039 from wowsims/guardian
Browse files Browse the repository at this point in the history
Tank metrics display improvements
  • Loading branch information
NerdEgghead authored Sep 20, 2024
2 parents ad24292 + 33de55d commit 1cca255
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
51 changes: 30 additions & 21 deletions ui/core/components/raid_sim_action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ export class RaidSimResultsManager {
this.formatToplineResult(
`.${RaidSimResultsManager.resultMetricClasses['cod']} .results-reference-diff`,
res => res.getFirstPlayer()!.chanceOfDeath,
1,
2,
true,
true,
);
} else {
Expand All @@ -330,6 +331,7 @@ export class RaidSimResultsManager {
getMetrics: (result: SimResult) => DistributionMetricsProto | number,
precision: number,
lowerIsBetter?: boolean,
preNormalizedErrors?: boolean,
) {
const elem = this.simUI.resultsViewer.contentElem.querySelector<HTMLSpanElement>(querySelector);
if (!elem) {
Expand All @@ -347,15 +349,15 @@ export class RaidSimResultsManager {
} else {
const curMetrics = curMetricsTemp as DistributionMetricsProto;
const refMetrics = refMetricsTemp as DistributionMetricsProto;
const isDiff = this.applyZTestTooltip(elem, ref.iterations, refMetrics.avg, refMetrics.stdev, cur.iterations, curMetrics.avg, curMetrics.stdev);
const isDiff = this.applyZTestTooltip(elem, ref.iterations, refMetrics.avg, refMetrics.stdev, cur.iterations, curMetrics.avg, curMetrics.stdev, !!preNormalizedErrors);
formatDeltaTextElem(elem, refMetrics.avg, curMetrics.avg, precision, lowerIsBetter, !isDiff);
}
}

private applyZTestTooltip(elem: HTMLElement, n1: number, avg1: number, stdev1: number, n2: number, avg2: number, stdev2: number): boolean {
private applyZTestTooltip(elem: HTMLElement, n1: number, avg1: number, stdev1: number, n2: number, avg2: number, stdev2: number, preNormalized: boolean): boolean {
const delta = avg1 - avg2;
const err1 = stdev1 / Math.sqrt(n1);
const err2 = stdev2 / Math.sqrt(n2);
const err1 = preNormalized ? stdev1 : stdev1 / Math.sqrt(n1);
const err2 = preNormalized ? stdev2 : stdev2 / Math.sqrt(n2);
const denom = Math.sqrt(Math.pow(err1, 2) + Math.pow(err2, 2));
const z = Math.abs(delta / denom);
const isDiff = z > 1.96;
Expand Down Expand Up @@ -455,15 +457,17 @@ export class RaidSimResultsManager {
}

resultColumns.push({
name: 'HPS',
name: 'TMI',
average: tmiMetrics.avg,
stdev: tmiMetrics.stdev,
classes: this.getResultsLineClasses('tmi'),
unit: 'percentage',
});

resultColumns.push({
name: 'COD',
average: chanceOfDeath,
average: chanceOfDeath.avg,
stdev: chanceOfDeath.stdev,
classes: this.getResultsLineClasses('cod'),
unit: 'percentage',
});
Expand Down Expand Up @@ -614,9 +618,11 @@ export class RaidSimResultsManager {
<tr>
{data.map(({ average, stdev, classes, unit }) => {
let value = '';
let errorDecimals = 0;
switch (unit) {
case 'percentage':
value = formatToPercent(average);
errorDecimals = 2;
break;
case 'seconds':
value = formatToNumber(average, { style: 'unit', unit: 'second', unitDisplay: 'narrow' });
Expand All @@ -630,7 +636,7 @@ export class RaidSimResultsManager {
<div className="topline-result-avg">{value}</div>
{stdev ? (
<div className="topline-result-stdev">
<i className="fas fa-plus-minus fa-xs"></i> {formatToNumber(stdev, { maximumFractionDigits: 0 })}
<i className="fas fa-plus-minus fa-xs"></i> {formatToNumber(stdev, { maximumFractionDigits: errorDecimals })}
</div>
) : undefined}
<div className="results-reference hide">
Expand All @@ -649,20 +655,23 @@ export class RaidSimResultsManager {
private static buildResultsList(data: ResultMetric[]): Element {
return (
<>
{data.map(column => (
<div className={`results-metric ${column.classes}`}>
<span className="topline-result-avg">{column.average.toFixed(2)}</span>
{column.stdev && (
<span className="topline-result-stdev">
(<i className="fas fa-plus-minus fa-xs"></i>
{column.stdev.toFixed()})
</span>
)}
<div className="results-reference hide">
<span className="results-reference-diff"></span> vs reference
{data.map(column => {
const errorDecimals = (column.unit === 'percentage') ? 2 : 0;
return (
<div className={`results-metric ${column.classes}`}>
<span className="topline-result-avg">{column.average.toFixed(2)}</span>
{column.stdev && (
<span className="topline-result-stdev">
(<i className="fas fa-plus-minus fa-xs"></i>
{column.stdev.toFixed(errorDecimals)})
</span>
)}
<div className="results-reference hide">
<span className="results-reference-diff"></span> vs reference
</div>
</div>
</div>
))}
);
})}
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions ui/core/constants/tooltips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const TOOLTIP_METRIC_LABELS = {
'Damage Taken': 'Total Damage taken',
DTPS: 'Damage Taken / Encounter Duration',
COD: 'Chance of Death',
TMI: 'Theck-Meloree Index',
// Cast metrics
Casts: 'Casts',
CPM: 'Casts / (Encounter Duration / 60 Seconds)',
Expand Down
10 changes: 8 additions & 2 deletions ui/core/proto_utils/sim_result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,14 @@ export class UnitMetrics {
}
}

get chanceOfDeath(): number {
return this.metrics.chanceOfDeath * 100;
get chanceOfDeath(): DistributionMetricsProto {
const p = this.metrics.chanceOfDeath;
const err = Math.sqrt(p * (1 - p) / this.iterations);

return DistributionMetricsProto.create({
avg: p * 100,
stdev: err * 100,
});
}

get maxThreat() {
Expand Down

0 comments on commit 1cca255

Please sign in to comment.