WIP: unfinished rendering-hud parity work, stopped for the night

Uncommitted changes the agent had in progress when it was stopped; may not
build or pass its harnesses yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-10 22:24:03 +02:00
parent 8ef3195457
commit 6e9f218a14
7 changed files with 767 additions and 227 deletions
+179 -115
View File
@@ -1,11 +1,13 @@
//! Headless transport for the HUD parity gate: replays each player state
//! through `horizon_client::hud_layout` (crosshair, hotbar, health, mount
//! hearts, experience bar and level) and writes the draw calls in vanilla's
//! GuiGraphicsExtractor terms.
//! Headless transport for the HUD parity gate: replays each case through
//! `horizon_client::hud_layout` and writes the draw calls in vanilla's
//! GuiGraphicsExtractor terms. Case kinds: `decorations` (crosshair,
//! hotbar, health, mount hearts, experience bar and level) and the
//! overlays handled in `kinds`.
#![forbid(unsafe_code)]
use horizon_client::{
hud::{HudAtlas, HudBatch},
hud_layout::{self, GuiDraw, HealthHud, HealthInputs, HeartKind, HotbarInputs},
hud_layout::{self, GuiDraw, HealthHud, HealthInputs, HeartKind, HotbarInputs, IDENTITY, Pose},
text::Text,
};
use serde_json::{Value, json};
use std::{
@@ -14,6 +16,8 @@ use std::{
path::PathBuf,
};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
#[path = "hud_fixture/kinds.rs"]
mod kinds;
fn main() -> Result<()> {
let args: Vec<PathBuf> = std::env::args_os().skip(1).map(PathBuf::from).collect();
@@ -27,117 +31,177 @@ fn main() -> Result<()> {
.filter(|l| !l.is_empty())
{
let c: Value = serde_json::from_str(line)?;
let int = |k: &str, d: i64| c[k].as_i64().unwrap_or(d) as i32;
let float = |k: &str, d: f64| c[k].as_f64().unwrap_or(d) as f32;
let (w, h) = (int("width", 0), int("height", 0));
let mode = c["gameMode"].as_str().unwrap_or("survival");
let survival = mode == "survival" || mode == "adventure";
let indicator = c["attackIndicator"].as_str().unwrap_or("OFF");
let partial = float("partial", 0.0);
let effects: Vec<&str> = c["effects"]
.as_array()
.into_iter()
.flatten()
.filter_map(Value::as_str)
.collect();
let has = |e: &str| effects.contains(&e);
let mut draws = Vec::new();
// Spectators only see it over a spectatable target (none here).
if c["crosshair"].as_bool().unwrap_or(false) && mode != "spectator" {
let attack = (indicator == "CROSSHAIR").then(|| float("attackScale", 1.0));
draws.extend(hud_layout::crosshair(w, h, attack, false));
}
if mode != "spectator" {
let pop = |v: &Value| v.as_f64().map(|p| p as f32 - partial);
let slots: [Option<f32>; 9] = std::array::from_fn(|i| pop(&c["slots"][i]));
let inputs = HotbarInputs {
selected: int("selected", 0),
right_handed: c["rightHanded"].as_bool().unwrap_or(true),
offhand: !c["offhand"].is_null(),
slots,
offhand_pop: pop(&c["offhand"]).unwrap_or(0.0),
attack: (indicator == "HOTBAR").then(|| float("attackScale", 1.0)),
};
draws.extend(hud_layout::hotbar(w, h, &inputs));
}
let vehicle_hearts = if c.get("vehicleMaxHealth").is_some() {
hud_layout::vehicle_max_hearts(float("vehicleMaxHealth", 0.0))
} else {
0
let draws = match c["kind"].as_str().unwrap_or("decorations") {
"decorations" => decorations(&c, &atlas),
kind => kinds::run(kind, &c, &atlas),
};
if survival {
let millis = 1_000_000_000i64;
let mut hud = HealthHud {
last_health: int("lastHealth", 0),
display_health: int("displayHealth", 0),
last_health_time: millis - i64::from(int("lastHealthAgo", 0)),
health_blink_time: i64::from(int("healthBlinkTime", 0)),
};
let kind = if has("minecraft:poison") {
HeartKind::Poisoned
} else if has("minecraft:wither") {
HeartKind::Withered
} else if c["frozen"].as_bool().unwrap_or(false) {
HeartKind::Frozen
} else {
HeartKind::Normal
};
let inputs = HealthInputs {
tick: int("tick", 0),
millis,
health: float("health", 20.0),
max_health: float("maxHealth", 20.0),
absorption: float("absorption", 0.0),
armor: int("armor", 0),
food: int("food", 20),
saturation: float("saturation", 5.0),
kind,
regeneration: has("minecraft:regeneration"),
hunger: has("minecraft:hunger"),
hardcore: c["hardcore"].as_bool().unwrap_or(false),
damage_cooldown: int("damageCooldown", 0) > 0,
air: int("air", 300),
max_air: int("maxAir", 300),
under_water: c["underWater"].as_bool().unwrap_or(false),
vehicle_hearts,
};
draws.extend(hud.layout(&inputs, w, h));
}
if vehicle_hearts > 0 {
draws.extend(hud_layout::vehicle_health(
w,
h,
vehicle_hearts,
float("vehicleHealth", 0.0),
));
}
let width = |s: &str| HudBatch::text_width(&atlas, s) as i32;
let level = if survival { int("xpLevel", 0) } else { 0 };
draws.extend(hud_layout::experience(
w,
h,
float("xpProgress", 0.0),
level,
c["experienceBar"].as_bool().unwrap_or(false),
&width,
));
let draws: Vec<Value> = draws
.iter()
.map(|d| match d {
GuiDraw::Sprite { sprite, x, y, w, h, region } => {
json!({"type": "sprite", "sprite": sprite, "x": x, "y": y, "w": w, "h": h, "region": region})
}
GuiDraw::Text { text, x, y, color, shadow } => {
json!({"type": "text", "text": text, "x": x, "y": y, "color": *color as i32, "shadow": shadow})
}
GuiDraw::Item { slot, x, y, seed, scale, pivot } => {
// translate(pivot) * scale * translate(-pivot) as a 3x2 matrix.
let m = [scale[0], 0.0, 0.0, scale[1], pivot[0] - pivot[0] * scale[0], pivot[1] - pivot[1] * scale[1]];
json!({"type": "item", "slot": slot, "x": x, "y": y, "seed": seed, "matrix": m})
}
})
.collect();
writeln!(out, "{}", json!({ "draws": draws }))?;
writeln!(out, "{}", json!({ "draws": encode(&draws) }))?;
}
Ok(())
}
/// Style runs of styled text: `[text, rgb|null, bold, italic]` per run of
/// equally styled characters, or none for plain text.
fn runs(t: &Text) -> Option<Value> {
let mut out: Vec<(String, Option<u32>, bool, bool)> = Vec::new();
let mut styled = false;
for (ch, s) in t.chars() {
let key = (s.color, s.is_bold(), s.is_italic());
styled |= key != (None, false, false);
match out.last_mut() {
Some(last) if (last.1, last.2, last.3) == key => last.0.push(ch),
_ => out.push((ch.to_string(), key.0, key.1, key.2)),
}
}
styled.then(|| json!(out.into_iter().map(|r| json!([r.0, r.1, r.2, r.3])).collect::<Vec<_>>()))
}
fn encode(draws: &[GuiDraw]) -> Vec<Value> {
let mut stack: Vec<Pose> = vec![IDENTITY];
let mut out = Vec::new();
for d in draws {
let pose = *stack.last().unwrap();
let mut v = match d {
GuiDraw::Push(ops) => {
let mut m = pose;
for op in ops {
hud_layout::pose_apply(&mut m, *op);
}
stack.push(m);
continue;
}
GuiDraw::Pop => {
stack.pop();
continue;
}
GuiDraw::Sprite { sprite, x, y, w, h, region, color } => {
json!({"type": "sprite", "sprite": sprite, "x": x, "y": y, "w": w, "h": h, "region": region, "color": *color as i32})
}
GuiDraw::AtlasSprite { sprite, x, y, w, h, color } => {
json!({"type": "atlas", "sprite": sprite, "x": x, "y": y, "w": w, "h": h, "color": *color as i32})
}
GuiDraw::Blit { texture, blend, x, y, w, h, uv, src, tex, color } => json!({
"type": "blit", "texture": format!("textures/{texture}.png"), "pipeline": blend.pipeline(),
"x": x, "y": y, "w": w, "h": h, "uv": uv, "src": src, "tex": tex, "color": *color as i32}),
GuiDraw::Fill { x0, y0, x1, y1, color } => {
json!({"type": "fill", "x0": x0, "y0": y0, "x1": x1, "y1": y1, "color": *color as i32})
}
GuiDraw::Text { text, x, y, color, shadow } => {
let mut v = json!({"type": "text", "text": text.plain(), "x": x, "y": y, "color": *color as i32, "shadow": shadow});
if let Some(r) = runs(text) {
v["runs"] = r;
}
v
}
GuiDraw::Item { slot, x, y, seed, scale, pivot } => {
// translate(pivot) * scale * translate(-pivot) as a 3x2 matrix.
let m = [scale[0], 0.0, 0.0, scale[1], pivot[0] - pivot[0] * scale[0], pivot[1] - pivot[1] * scale[1]];
out.push(json!({"type": "item", "slot": slot, "x": x, "y": y, "seed": seed, "matrix": m}));
continue;
}
};
if pose != IDENTITY {
v["matrix"] = json!(pose);
}
out.push(v);
}
out
}
fn decorations(c: &Value, atlas: &HudAtlas) -> Vec<GuiDraw> {
let int = |k: &str, d: i64| c[k].as_i64().unwrap_or(d) as i32;
let float = |k: &str, d: f64| c[k].as_f64().unwrap_or(d) as f32;
let (w, h) = (int("width", 0), int("height", 0));
let mode = c["gameMode"].as_str().unwrap_or("survival");
let survival = mode == "survival" || mode == "adventure";
let indicator = c["attackIndicator"].as_str().unwrap_or("OFF");
let partial = float("partial", 0.0);
let effects: Vec<&str> = c["effects"]
.as_array()
.into_iter()
.flatten()
.filter_map(Value::as_str)
.collect();
let has = |e: &str| effects.contains(&e);
let mut draws = Vec::new();
// Spectators only see it over a spectatable target (none here).
if c["crosshair"].as_bool().unwrap_or(false) && mode != "spectator" {
let attack = (indicator == "CROSSHAIR").then(|| float("attackScale", 1.0));
draws.extend(hud_layout::crosshair(w, h, attack, false));
}
if mode != "spectator" {
let pop = |v: &Value| v.as_f64().map(|p| p as f32 - partial);
let slots: [Option<f32>; 9] = std::array::from_fn(|i| pop(&c["slots"][i]));
let inputs = HotbarInputs {
selected: int("selected", 0),
right_handed: c["rightHanded"].as_bool().unwrap_or(true),
offhand: !c["offhand"].is_null(),
slots,
offhand_pop: pop(&c["offhand"]).unwrap_or(0.0),
attack: (indicator == "HOTBAR").then(|| float("attackScale", 1.0)),
};
draws.extend(hud_layout::hotbar(w, h, &inputs));
}
let vehicle_hearts = if c.get("vehicleMaxHealth").is_some() {
hud_layout::vehicle_max_hearts(float("vehicleMaxHealth", 0.0))
} else {
0
};
if survival {
let millis = 1_000_000_000i64;
let mut hud = HealthHud {
last_health: int("lastHealth", 0),
display_health: int("displayHealth", 0),
last_health_time: millis - i64::from(int("lastHealthAgo", 0)),
health_blink_time: i64::from(int("healthBlinkTime", 0)),
};
let kind = if has("minecraft:poison") {
HeartKind::Poisoned
} else if has("minecraft:wither") {
HeartKind::Withered
} else if c["frozen"].as_bool().unwrap_or(false) {
HeartKind::Frozen
} else {
HeartKind::Normal
};
let inputs = HealthInputs {
tick: int("tick", 0),
millis,
health: float("health", 20.0),
max_health: float("maxHealth", 20.0),
absorption: float("absorption", 0.0),
armor: int("armor", 0),
food: int("food", 20),
saturation: float("saturation", 5.0),
kind,
regeneration: has("minecraft:regeneration"),
hunger: has("minecraft:hunger"),
hardcore: c["hardcore"].as_bool().unwrap_or(false),
damage_cooldown: int("damageCooldown", 0) > 0,
air: int("air", 300),
max_air: int("maxAir", 300),
under_water: c["underWater"].as_bool().unwrap_or(false),
vehicle_hearts,
};
draws.extend(hud.layout(&inputs, w, h));
}
if vehicle_hearts > 0 {
draws.extend(hud_layout::vehicle_health(
w,
h,
vehicle_hearts,
float("vehicleHealth", 0.0),
));
}
let width = |s: &str| HudBatch::text_width(atlas, s) as i32;
let level = if survival { int("xpLevel", 0) } else { 0 };
draws.extend(hud_layout::experience(
w,
h,
float("xpProgress", 0.0),
level,
c["experienceBar"].as_bool().unwrap_or(false),
&width,
));
draws
}
@@ -0,0 +1,9 @@
//! The overlay case kinds of the HUD parity fixture.
use horizon_client::{hud::HudAtlas, hud_layout::GuiDraw};
use serde_json::Value;
pub fn run(kind: &str, _c: &Value, _atlas: &HudAtlas) -> Vec<GuiDraw> {
match kind {
_ => Vec::new(),
}
}
@@ -0,0 +1,65 @@
//! The player's attack strength (`Player.attackStrengthTicker`,
//! `itemSwapTicker`, `getAttackStrengthScale`, `getCurrentItemAttackStrengthDelay`):
//! the charge the attack indicator shows and attacks scale their damage by.
/// `Attributes.ATTACK_SPEED` base value.
pub const BASE_ATTACK_SPEED: f64 = 4.0;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AttackStrength {
/// `LivingEntity.attackStrengthTicker`.
pub ticker: i32,
/// `LivingEntity.itemSwapTicker`.
pub swap_ticker: i32,
/// `Player.lastItemInMainHand`: the stack as last compared.
last_item: Option<HeldStack>,
}
/// What `ItemStack.matches` / `isSameItem` compare of the main-hand stack:
/// its item id and the rest of the stack (count and components) as a key.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct HeldStack {
pub item: String,
pub rest: String,
}
/// `Player.getCurrentItemAttackStrengthDelay` for an ATTACK_SPEED value.
pub fn delay(attack_speed: f64) -> f32 {
(1.0 / attack_speed * 20.0) as f32
}
impl AttackStrength {
/// The attack-strength part of `Player.tick`: both tickers advance, and a
/// main-hand change to a different item resets them
/// (`!ItemStack.matches` and `!ItemStack.isSameItem`).
pub fn tick(&mut self, main_hand: Option<HeldStack>) {
self.ticker += 1;
self.swap_ticker += 1;
if self.last_item != main_hand {
let same_item = match (&self.last_item, &main_hand) {
(Some(a), Some(b)) => a.item == b.item,
(None, None) => true,
_ => false,
};
if !same_item {
self.reset();
}
self.last_item = main_hand;
}
}
/// `resetAttackStrengthTicker`: swinging at nothing, attacking or
/// stopping a block break.
pub fn reset(&mut self) {
self.ticker = 0;
self.swap_ticker = 0;
}
/// `resetOnlyAttackStrengthTicker` (`Player.onAttack`).
pub fn reset_attack(&mut self) {
self.ticker = 0;
}
/// `getAttackStrengthScale(a)` with the ATTACK_SPEED attribute value.
pub fn scale(&self, a: f32, attack_speed: f64) -> f32 {
((self.ticker as f32 + a) / delay(attack_speed)).clamp(0.0, 1.0)
}
/// `getItemSwapScale(a)`.
pub fn swap_scale(&self, a: f32, attack_speed: f64) -> f32 {
((self.swap_ticker as f32 + a) / delay(attack_speed)).clamp(0.0, 1.0)
}
}
+319 -54
View File
@@ -1,26 +1,110 @@
//! Layout of vanilla's `Hud` decorations as draw calls (`GuiGraphicsExtractor`
//! blits and text): the hotbar with its selection, off-hand slot, items and
//! Layout of vanilla's `Hud` as draw calls (`GuiGraphicsExtractor` blits,
//! fills and text): the hotbar with its selection, off-hand slot, items and
//! attack indicator, the crosshair, armour, hearts, food, air bubbles, mount
//! hearts and the experience bar and level. Computed without drawing so the
//! parity fixture can compare them with the vanilla client.
//! hearts, the experience and jump bars, status effect icons, camera
//! overlays, titles and the action bar, the selected item name, boss bars,
//! the scoreboard sidebar, chat and item decorations. Computed without
//! drawing so the parity fixture can compare them with the vanilla client.
use crate::{font::Font, text::Text};
use horizon_core::random::{LegacyRandom, RandomSource};
use std::borrow::Cow;
/// A `Matrix3x2fStack` operation applied to a copy of the current pose.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PoseOp {
Translate(f32, f32),
Scale(f32, f32),
}
/// A JOML `Matrix3x2f` as `[m00, m01, m10, m11, m20, m21]`.
pub type Pose = [f32; 6];
pub const IDENTITY: Pose = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0];
/// Applies `op` like JOML's `translate` / `scale` (same float order).
pub fn pose_apply(m: &mut Pose, op: PoseOp) {
match op {
PoseOp::Translate(x, y) => {
m[4] += m[0] * x + m[2] * y;
m[5] += m[1] * x + m[3] * y;
}
PoseOp::Scale(x, y) => {
m[0] *= x;
m[1] *= x;
m[2] *= y;
m[3] *= y;
}
}
}
/// The render pipeline of a texture blit.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Blend {
/// `GUI_TEXTURED`.
Textured,
/// `VIGNETTE`: `dst * (1 - src)`.
Vignette,
/// `GUI_NAUSEA_OVERLAY`: additive.
Nausea,
}
impl Blend {
pub fn pipeline(self) -> &'static str {
match self {
Blend::Textured => "pipeline/gui_textured",
Blend::Vignette => "pipeline/vignette",
Blend::Nausea => "pipeline/gui_nausea_overlay",
}
}
}
/// One `GuiGraphicsExtractor` call.
#[derive(Clone, Debug, PartialEq)]
pub enum GuiDraw {
/// `blitSprite(sprite, x, y, w, h)`; `region` = (spriteW, spriteH, u, v)
/// for the partial overload.
/// `blitSprite(sprite, x, y, w, h, color)`; `region` = (spriteW,
/// spriteH, u, v) for the partial overload.
Sprite {
sprite: &'static str,
sprite: Cow<'static, str>,
x: i32,
y: i32,
w: i32,
h: i32,
region: Option<[i32; 4]>,
color: u32,
},
/// `blitSprite(pipeline, TextureAtlasSprite, ...)` with a block atlas
/// sprite (the nether portal overlay).
AtlasSprite {
sprite: Cow<'static, str>,
x: i32,
y: i32,
w: i32,
h: i32,
color: u32,
},
/// `blit(pipeline, texture, x, y, u, v, w, h, srcW, srcH, texW, texH,
/// color)`; `texture` is the path under `textures/` without `.png`.
Blit {
texture: Cow<'static, str>,
blend: Blend,
x: i32,
y: i32,
w: i32,
h: i32,
uv: [f32; 2],
src: [i32; 2],
tex: [i32; 2],
color: u32,
},
/// `fill(x0, y0, x1, y1, color)` with the corners sorted.
Fill {
x0: i32,
y0: i32,
x1: i32,
y1: i32,
color: u32,
},
/// `text(font, text, x, y, argb, dropShadow)`.
Text {
text: String,
text: Text,
x: i32,
y: i32,
color: u32,
@@ -36,17 +120,130 @@ pub enum GuiDraw {
scale: [f32; 2],
pivot: [f32; 2],
},
/// `pose().pushMatrix()` followed by `ops`.
Push(Vec<PoseOp>),
/// `pose().popMatrix()`.
Pop,
}
pub const WHITE: u32 = 0xFFFF_FFFF;
fn sprite(sprite: &'static str, x: i32, y: i32, w: i32, h: i32) -> GuiDraw {
GuiDraw::Sprite {
sprite,
sprite: Cow::Borrowed(sprite),
x,
y,
w,
h,
region: None,
color: WHITE,
}
}
fn region(sprite: &'static str, size: [i32; 2], uv: [i32; 2], at: [i32; 2], w: i32, h: i32) -> GuiDraw {
GuiDraw::Sprite {
sprite: Cow::Borrowed(sprite),
x: at[0],
y: at[1],
w,
h,
region: Some([size[0], size[1], uv[0], uv[1]]),
color: WHITE,
}
}
/// `graphics.fill`: the corners are sorted.
pub fn fill(x0: i32, y0: i32, x1: i32, y1: i32, color: u32) -> GuiDraw {
GuiDraw::Fill {
x0: x0.min(x1),
y0: y0.min(y1),
x1: x0.max(x1),
y1: y0.max(y1),
color,
}
}
/// `graphics.text`: dropped when fully transparent.
fn text(out: &mut Vec<GuiDraw>, text: Text, x: i32, y: i32, color: u32, shadow: bool) {
if color >> 24 != 0 {
out.push(GuiDraw::Text {
text,
x,
y,
color,
shadow,
});
}
}
/// `graphics.textWithBackdrop` under `background` = `Options.getBackgroundColor(0)`.
fn text_with_backdrop(out: &mut Vec<GuiDraw>, t: Text, x: i32, y: i32, w: i32, color: u32, background: u32) {
if background != 0 {
out.push(fill(x - 2, y - 2, x + w + 2, y + 9 + 2, multiply(background, color)));
}
text(out, t, x, y, color, true);
}
/// `Options.getBackgroundColor(float)`: `chat_only` = `backgroundForChatOnly`.
pub fn background_color(chat_only: bool, opacity: f64, default: f32) -> u32 {
let a = if chat_only { default } else { opacity as f32 };
color_from_float(a, 0.0, 0.0, 0.0)
}
/// `Mth.floor`.
pub fn floor(x: f32) -> i32 {
let i = x as i32;
if x < i as f32 { i - 1 } else { i }
}
/// `ARGB.as8BitChannel`.
pub fn as8(v: f32) -> u32 {
floor(v * 255.0) as u32
}
/// `ARGB.white(float)`.
pub fn white(alpha: f32) -> u32 {
(as8(alpha) << 24) | 0xFF_FFFF
}
/// `ARGB.colorFromFloat`.
pub fn color_from_float(a: f32, r: f32, g: f32, b: f32) -> u32 {
argb(as8(a), as8(r), as8(g), as8(b))
}
/// `ARGB.color(a, r, g, b)`.
pub fn argb(a: u32, r: u32, g: u32, b: u32) -> u32 {
(a & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | (b & 255)
}
/// `ARGB.multiply`.
pub fn multiply(l: u32, r: u32) -> u32 {
if l == WHITE {
return r;
}
if r == WHITE {
return l;
}
let c = |s: u32| ((l >> s) & 255) * ((r >> s) & 255) / 255;
argb(c(24), c(16), c(8), c(0))
}
/// `Mth.lerpDiscrete`.
pub fn lerp_discrete(alpha: f32, p0: i32, p1: i32) -> i32 {
p0 + floor(alpha * (p1 - p0 - 1) as f32) + i32::from(alpha > 0.0)
}
/// `Mth.hsvToArgb`.
pub fn hsv_to_argb(hue: f32, saturation: f32, value: f32, alpha: u32) -> u32 {
let h = (hue * 6.0) as i32 % 6;
let f = hue * 6.0 - h as f32;
let p = value * (1.0 - saturation);
let q = value * (1.0 - f * saturation);
let t = value * (1.0 - (1.0 - f) * saturation);
let (r, g, b) = match h {
0 => (value, t, p),
1 => (q, value, p),
2 => (p, value, t),
3 => (p, q, value),
4 => (t, p, value),
_ => (value, p, q),
};
let c = |v: f32| ((v * 255.0) as i32).clamp(0, 255) as u32;
argb(alpha, c(r), c(g), c(b))
}
/// `Font.width` of styled text.
pub fn width(font: &Font, t: &Text) -> i32 {
font.width_text(t) as i32
}
/// `Hud.extractItemHotbar` inputs.
pub struct HotbarInputs {
@@ -153,14 +350,14 @@ pub fn hotbar(w: i32, h: i32, i: &HotbarInputs) -> Vec<GuiDraw> {
18,
18,
));
out.push(GuiDraw::Sprite {
sprite: "hud/hotbar_attack_indicator_progress",
x,
y: y + 18 - progress,
w: 18,
h: progress,
region: Some([18, 18, 0, 18 - progress]),
});
out.push(region(
"hud/hotbar_attack_indicator_progress",
[18, 18],
[0, 18 - progress],
[x, y + 18 - progress],
18,
progress,
));
}
out
}
@@ -183,14 +380,14 @@ pub fn crosshair(w: i32, h: i32, attack: Option<f32>, full: bool) -> Vec<GuiDraw
16,
4,
));
out.push(GuiDraw::Sprite {
sprite: "hud/crosshair_attack_indicator_progress",
x,
y,
w: progress,
h: 4,
region: Some([16, 4, 0, 0]),
});
out.push(region(
"hud/crosshair_attack_indicator_progress",
[16, 4],
[0, 0],
[x, y],
progress,
4,
));
}
}
out
@@ -212,14 +409,14 @@ pub fn experience(
let filled = (progress * 183.0) as i32;
out.push(sprite("hud/experience_bar_background", left, top, 182, 5));
if filled > 0 {
out.push(GuiDraw::Sprite {
sprite: "hud/experience_bar_progress",
x: left,
y: top,
w: filled,
h: 5,
region: Some([182, 5, 0, 0]),
});
out.push(region(
"hud/experience_bar_progress",
[182, 5],
[0, 0],
[left, top],
filled,
5,
));
}
}
if level > 0 {
@@ -227,21 +424,9 @@ pub fn experience(
let x = (w - width(&text)) / 2;
let y = h - 24 - 9 - 2;
for (dx, dy) in [(1, 0), (-1, 0), (0, 1), (0, -1)] {
out.push(GuiDraw::Text {
text: text.clone(),
x: x + dx,
y: y + dy,
color: 0xFF00_0000,
shadow: false,
});
self::text(&mut out, Text::literal(&text), x + dx, y + dy, 0xFF00_0000, false);
}
out.push(GuiDraw::Text {
text,
x,
y,
color: 0xFF80_FF20,
shadow: false,
});
self::text(&mut out, Text::literal(text), x, y, 0xFF80_FF20, false);
}
out
}
@@ -554,10 +739,14 @@ impl HealthHud {
}
}
/// Draws the sprite and text calls with the HUD batch; items are left to the
/// caller (they need the item renderer).
/// Draws the calls with the HUD batch under their poses; items are left to
/// the caller (they need the item renderer) and so are the vignette and
/// nausea blits (their blending needs the screen-effect pipeline).
pub fn paint(batch: &mut crate::hud::HudBatch, atlas: &crate::hud::HudAtlas, draws: &[GuiDraw]) {
let mut stack = vec![IDENTITY];
for d in draws {
let start = batch.vertices.len();
let pose = *stack.last().unwrap_or(&IDENTITY);
match d {
GuiDraw::Sprite {
sprite,
@@ -566,6 +755,7 @@ pub fn paint(batch: &mut crate::hud::HudBatch, atlas: &crate::hud::HudAtlas, dra
w,
h,
region,
color,
} => {
let Some(mut r) = atlas.sprites.get(&format!("gui/sprites/{sprite}")).copied()
else {
@@ -580,7 +770,58 @@ pub fn paint(batch: &mut crate::hud::HudBatch, atlas: &crate::hud::HudAtlas, dra
r.u0 = u0;
r.v0 = v0;
}
batch.rect_uv(*x as f32, *y as f32, *w as f32, *h as f32, r, u32::MAX);
batch.rect_uv(*x as f32, *y as f32, *w as f32, *h as f32, r, abgr(*color));
}
GuiDraw::AtlasSprite {
sprite,
x,
y,
w,
h,
color,
} => {
batch.sprite_scaled(atlas, sprite, *x as f32, *y as f32, *w as f32, *h as f32, abgr(*color));
}
GuiDraw::Blit {
texture,
blend: Blend::Textured,
x,
y,
w,
h,
uv,
src,
tex,
color,
} => {
let Some(mut r) = atlas.sprites.get(texture.as_ref()).copied() else {
continue;
};
let (du, dv) = (r.u1 - r.u0, r.v1 - r.v0);
let u0 = r.u0 + du * uv[0] / tex[0] as f32;
let v0 = r.v0 + dv * uv[1] / tex[1] as f32;
r.u1 = r.u0 + du * (uv[0] + src[0] as f32) / tex[0] as f32;
r.v1 = r.v0 + dv * (uv[1] + src[1] as f32) / tex[1] as f32;
r.u0 = u0;
r.v0 = v0;
batch.rect_uv(*x as f32, *y as f32, *w as f32, *h as f32, r, abgr(*color));
}
GuiDraw::Blit { .. } | GuiDraw::Item { .. } => {}
GuiDraw::Fill {
x0,
y0,
x1,
y1,
color,
} => {
batch.fill(
atlas,
*x0 as f32,
*y0 as f32,
(x1 - x0) as f32,
(y1 - y0) as f32,
abgr(*color),
);
}
GuiDraw::Text {
text,
@@ -589,11 +830,35 @@ pub fn paint(batch: &mut crate::hud::HudBatch, atlas: &crate::hud::HudAtlas, dra
color,
shadow,
} => {
let [a, r, g, b] = color.to_be_bytes();
let rgba = crate::hud::rgba(r, g, b, a);
batch.text(atlas, text, *x as f32, *y as f32, rgba, *shadow);
batch.text_styled(atlas, text, *x as f32, *y as f32, abgr(*color), *shadow);
}
GuiDraw::Push(ops) => {
let mut m = pose;
for op in ops {
pose_apply(&mut m, *op);
}
stack.push(m);
}
GuiDraw::Pop => {
if stack.len() > 1 {
stack.pop();
}
}
}
if pose != IDENTITY {
for v in &mut batch.vertices[start..] {
let [x, y] = v.pos;
v.pos = [
pose[0] * x + pose[2] * y + pose[4],
pose[1] * x + pose[3] * y + pose[5],
];
}
GuiDraw::Item { .. } => {}
}
}
}
/// An ARGB colour as the HUD batch's packed RGBA.
pub fn abgr(color: u32) -> u32 {
let [a, r, g, b] = color.to_be_bytes();
crate::hud::rgba(r, g, b, a)
}
@@ -56,6 +56,7 @@ public final class VanillaHudOracle {
static Object unsafe;
static Method allocate;
static JsonObject c;
static Font FONT;
static IdentityHashMap<ItemStack, Integer> slots = new IdentityHashMap<>();
@SuppressWarnings("unchecked")
@@ -134,6 +135,16 @@ public final class VanillaHudOracle {
@Override public int guiHeight() { return i("height", 0); }
@Override public Matrix3x2fStack pose() { return stack; }
@Override public void nextStratum() { }
/** Adds the pose when it is not the identity. */
JsonObject posed(JsonObject o, org.joml.Matrix3x2fc m) {
if (!m.equals(new Matrix3x2f())) {
var a = new JsonArray();
for (float v : new float[] {m.m00(), m.m01(), m.m10(), m.m11(), m.m20(), m.m21()}) a.add(v);
o.add("matrix", a);
}
draws.add(o);
return o;
}
void sprite(Identifier id, int x, int y, int w, int h, int[] region, int color) {
var o = new JsonObject();
o.addProperty("type", "sprite");
@@ -145,20 +156,86 @@ public final class VanillaHudOracle {
o.add("region", r);
}
o.addProperty("color", color);
draws.add(o);
posed(o, stack);
}
@Override public void blitSprite(RenderPipeline p, Identifier id, int x, int y, int w, int h, int color) { sprite(id, x, y, w, h, null, color); }
@Override public void blitSprite(RenderPipeline p, Identifier id, int sw, int sh, int u, int v, int x, int y, int w, int h, int color) {
sprite(id, x, y, w, h, new int[] {sw, sh, u, v}, color);
}
@Override public void text(Font font, FormattedCharSequence str, int x, int y, int color, boolean shadow) {
@Override public void blitSprite(RenderPipeline p, net.minecraft.client.renderer.texture.TextureAtlasSprite s, int x, int y, int w, int h, int color) {
var o = new JsonObject();
o.addProperty("type", "atlas");
o.addProperty("sprite", s.contents().name().getPath());
o.addProperty("x", x); o.addProperty("y", y); o.addProperty("w", w); o.addProperty("h", h);
o.addProperty("color", color);
posed(o, stack);
}
@Override public void blit(RenderPipeline p, Identifier texture, int x, int y, float u, float v, int w, int h, int srcW, int srcH, int texW, int texH, int color) {
var o = new JsonObject();
o.addProperty("type", "blit");
o.addProperty("texture", texture.getPath());
o.addProperty("pipeline", p.getLocation().getPath());
o.addProperty("x", x); o.addProperty("y", y); o.addProperty("w", w); o.addProperty("h", h);
var uv = new JsonArray(); uv.add(u); uv.add(v); o.add("uv", uv);
var src = new JsonArray(); src.add(srcW); src.add(srcH); o.add("src", src);
var tex = new JsonArray(); tex.add(texW); tex.add(texH); o.add("tex", tex);
o.addProperty("color", color);
posed(o, stack);
}
@Override public void fill(RenderPipeline p, int x0, int y0, int x1, int y1, int color) {
var o = new JsonObject();
o.addProperty("type", "fill");
o.addProperty("x0", Math.min(x0, x1)); o.addProperty("y0", Math.min(y0, y1));
o.addProperty("x1", Math.max(x0, x1)); o.addProperty("y1", Math.max(y0, y1));
o.addProperty("color", color);
posed(o, stack);
}
void text(FormattedCharSequence str, int x, int y, int color, boolean shadow, org.joml.Matrix3x2fc pose) {
var o = new JsonObject();
o.addProperty("type", "text");
var sb = new StringBuilder();
str.accept((index, style, cp) -> { sb.appendCodePoint(cp); return true; });
var runs = new JsonArray();
boolean[] styled = {false};
str.accept((index, style, cp) -> {
sb.appendCodePoint(cp);
Integer rgb = style.getColor() == null ? null : style.getColor().getValue();
boolean bold = style.isBold(), italic = style.isItalic();
styled[0] |= rgb != null || bold || italic;
JsonArray last = runs.isEmpty() ? null : runs.get(runs.size() - 1).getAsJsonArray();
if (last != null && java.util.Objects.equals(last.get(1).isJsonNull() ? null : last.get(1).getAsInt(), rgb)
&& last.get(2).getAsBoolean() == bold && last.get(3).getAsBoolean() == italic) {
last.set(0, new JsonPrimitive(last.get(0).getAsString() + new String(Character.toChars(cp))));
} else {
var run = new JsonArray();
run.add(new String(Character.toChars(cp)));
if (rgb == null) run.add(JsonNull.INSTANCE); else run.add(rgb);
run.add(bold); run.add(italic);
runs.add(run);
}
return true;
});
o.addProperty("text", sb.toString());
o.addProperty("x", x); o.addProperty("y", y); o.addProperty("color", color); o.addProperty("shadow", shadow);
draws.add(o);
if (styled[0]) o.add("runs", runs);
posed(o, pose);
}
@Override public void text(Font font, FormattedCharSequence str, int x, int y, int color, boolean shadow) {
if (net.minecraft.util.ARGB.alpha(color) != 0) text(str, x, y, color, shadow, stack);
}
/** The chat's text collector: text at the parameters' pose and opacity. */
@Override public net.minecraft.client.gui.ActiveTextCollector textRenderer(GuiGraphicsExtractor.HoveredTextEffects effects, java.util.function.Consumer<net.minecraft.network.chat.Style> consumer) {
var self = this;
return new net.minecraft.client.gui.ActiveTextCollector() {
Parameters parameters = new Parameters(new Matrix3x2f(stack), 1.0F, null);
@Override public Parameters defaultParameters() { return parameters; }
@Override public void defaultParameters(Parameters p) { parameters = p; }
@Override public void accept(net.minecraft.client.gui.TextAlignment alignment, int anchorX, int y, Parameters p, FormattedCharSequence text) {
int left = alignment.calculateLeft(anchorX, FONT, text);
if (net.minecraft.util.ARGB.as8BitChannel(p.opacity()) != 0)
self.text(text, left, y, net.minecraft.util.ARGB.white(p.opacity()), true, p.pose());
}
@Override public void acceptScrolling(net.minecraft.network.chat.Component m, int cx, int l, int r, int t, int b, Parameters p) { }
};
}
@Override public void item(LivingEntity owner, ItemStack stack, int x, int y, int seed) {
var o = new JsonObject();
@@ -180,7 +257,7 @@ public final class VanillaHudOracle {
unsafeField.setAccessible(true);
unsafe = unsafeField.get(null);
allocate = unsafe.getClass().getMethod("allocateInstance", Class.class);
Font font = ParityFont.create(ParityFont.resources());
Font font = FONT = ParityFont.create(ParityFont.resources());
Method hotbar = Hud.class.getDeclaredMethod("extractItemHotbar", GuiGraphicsExtractor.class, DeltaTracker.class);
Method health = Hud.class.getDeclaredMethod("extractPlayerHealth", GuiGraphicsExtractor.class);
Method vehicle = Hud.class.getDeclaredMethod("extractVehicleHealth", GuiGraphicsExtractor.class);
+46
View File
@@ -0,0 +1,46 @@
"""Random HUD cases for test_hud_parity.py, one generator per case kind."""
EFFECTS = ['minecraft:poison', 'minecraft:wither', 'minecraft:regeneration', 'minecraft:hunger', 'minecraft:speed']
def decorations(rng, n):
max_health = rng.choice([20.0, 20.0, 6.0, 40.0, 33.0, 100.0])
health = rng.choice([max_health, round(rng.uniform(0, max_health), 2), 1.0, 0.5, 3.0])
air_max = 300
under = rng.random() < 0.3
air = rng.choice([air_max, rng.randint(-20, air_max), 0, 1, 29, 30, 31, 299]) if under or rng.random() < 0.2 else air_max
case = {
'width': rng.choice([427, 320, 480, 640, 961]), 'height': rng.choice([240, 255, 270, 360, 501]),
'gameMode': rng.choice(['survival'] * 5 + ['adventure', 'creative', 'spectator']),
'crosshair': rng.random() < 0.7,
'attackIndicator': rng.choice(['OFF', 'CROSSHAIR', 'HOTBAR']),
'attackScale': rng.choice([1.0, round(rng.random(), 3), 0.0, 0.999]),
'selected': rng.randint(0, 8), 'rightHanded': rng.random() < 0.7,
'slots': [rng.choice([None, 0, 0, 3, 5]) if rng.random() < 0.6 else None for _ in range(9)],
'offhand': rng.choice([None, None, 0, 4]), 'partial': round(rng.random(), 3),
'health': health, 'maxHealth': max_health,
'absorption': rng.choice([0.0, 0.0, 4.0, 3.5, 17.0, 40.0]),
'armor': rng.choice([0, 0, 1, 7, 20, 13]), 'food': rng.randint(0, 20),
'saturation': rng.choice([0.0, 5.0, 0.0]),
'effects': [e for e in EFFECTS if rng.random() < 0.15], 'frozen': rng.random() < 0.08,
'hardcore': rng.random() < 0.2, 'damageCooldown': rng.choice([0, 0, 10]),
'air': air, 'maxAir': air_max, 'underWater': under,
'tick': rng.randint(0, 100000), 'lastHealth': rng.randint(0, 40), 'displayHealth': rng.randint(0, 40),
'lastHealthAgo': rng.choice([0, 500, 5000]), 'healthBlinkTime': 0,
'xpProgress': rng.choice([0.0, round(rng.random(), 4), 0.999]), 'xpLevel': rng.choice([0, 1, 7, 30, 123, 4000]),
'experienceBar': rng.random() < 0.8,
}
if case['damageCooldown'] and rng.random() < 0.5:
case['healthBlinkTime'] = case['tick'] + rng.randint(1, 20)
if rng.random() < 0.15:
case['vehicleMaxHealth'] = rng.choice([15.0, 30.0, 53.0, 100.0])
case['vehicleHealth'] = round(rng.uniform(0, case['vehicleMaxHealth']), 1)
return case
# Generators by kind: (rng, index) -> case. Cases are drawn round-robin.
KINDS = {
'decorations': decorations,
}
+67 -53
View File
@@ -1,15 +1,23 @@
#!/usr/bin/env python3
"""Compare the in-game HUD decorations with the vanilla 26.3 client's Hud.
"""Compare the in-game HUD with the vanilla 26.3 client's Hud.
The Java oracle (VanillaHudOracle) runs vanilla's own Hud.extractCrosshair,
extractItemHotbar, extractPlayerHealth, extractVehicleHealth, ExperienceBar
and ContextualBar.extractExperienceLevel on a stand-in client whose player
answers from the case, and records every blit (sprite, position, size,
partial region), text call (string, position, colour, shadow) and hotbar
item (slot, position, seed, pose). `examples/hud_fixture` lays out the same
state with `horizon_client::hud_layout`; the ordered call lists must agree.
The Java oracle (VanillaHudOracle) runs vanilla's own Hud methods
(extractCrosshair, extractItemHotbar, extractPlayerHealth,
extractVehicleHealth, extractEffects, extractCameraOverlays, extractTitle,
extractOverlayMessage, extractSelectedItemName, the scoreboard sidebar and
Hud.tick), BossHealthOverlay, ChatComponent, the contextual bars and
GuiGraphicsExtractor.itemDecorations on a stand-in client whose player
answers from the case, and records every blit (sprite, texture, position,
size, region, colour, pose), fill, text call (string, style runs, position,
colour, shadow, pose) and hotbar item (slot, position, seed, pose).
`examples/hud_fixture` lays out the same state with
`horizon_client::hud_layout`; the ordered call lists must agree.
test_hud_parity.py [--count N] [--detail N]
Each case has a `kind` (decorations, effects, title, selected, boss,
sidebar, jump, decor, overlays, chat); timing kinds replay events tick by
tick (title fades, the action bar, the selected item name, chat fades).
test_hud_parity.py [--count N] [--detail N] [--kind K]
"""
import argparse
import json
@@ -20,62 +28,69 @@ import sys
try:
from . import lab, test_rust_parity as base, test_model_baking_parity as baking
from .hud_parity_cases import KINDS
except ImportError:
import lab, test_rust_parity as base, test_model_baking_parity as baking
from hud_parity_cases import KINDS
PARITY = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity'
EFFECTS = ['minecraft:poison', 'minecraft:wither', 'minecraft:regeneration', 'minecraft:hunger', 'minecraft:speed']
def cases(count):
def cases(count, kinds):
rng = random.Random(0x485544)
out = []
for n in range(count):
max_health = rng.choice([20.0, 20.0, 6.0, 40.0, 33.0, 100.0])
health = rng.choice([max_health, round(rng.uniform(0, max_health), 2), 1.0, 0.5, 3.0])
air_max = 300
under = rng.random() < 0.3
air = rng.choice([air_max, rng.randint(-20, air_max), 0, 1, 29, 30, 31, 299]) if under or rng.random() < 0.2 else air_max
case = {
'width': rng.choice([427, 320, 480, 640, 961]), 'height': rng.choice([240, 255, 270, 360, 501]),
'gameMode': rng.choice(['survival'] * 5 + ['adventure', 'creative', 'spectator']),
'crosshair': rng.random() < 0.7,
'attackIndicator': rng.choice(['OFF', 'CROSSHAIR', 'HOTBAR']),
'attackScale': rng.choice([1.0, round(rng.random(), 3), 0.0, 0.999]),
'selected': rng.randint(0, 8), 'rightHanded': rng.random() < 0.7,
'slots': [rng.choice([None, 0, 0, 3, 5]) if rng.random() < 0.6 else None for _ in range(9)],
'offhand': rng.choice([None, None, 0, 4]), 'partial': round(rng.random(), 3),
'health': health, 'maxHealth': max_health,
'absorption': rng.choice([0.0, 0.0, 4.0, 3.5, 17.0, 40.0]),
'armor': rng.choice([0, 0, 1, 7, 20, 13]), 'food': rng.randint(0, 20),
'saturation': rng.choice([0.0, 5.0, 0.0]),
'effects': [e for e in EFFECTS if rng.random() < 0.15], 'frozen': rng.random() < 0.08,
'hardcore': rng.random() < 0.2, 'damageCooldown': rng.choice([0, 0, 10]),
'air': air, 'maxAir': air_max, 'underWater': under,
'tick': rng.randint(0, 100000), 'lastHealth': rng.randint(0, 40), 'displayHealth': rng.randint(0, 40),
'lastHealthAgo': rng.choice([0, 500, 5000]), 'healthBlinkTime': 0,
'xpProgress': rng.choice([0.0, round(rng.random(), 4), 0.999]), 'xpLevel': rng.choice([0, 1, 7, 30, 123, 4000]),
'experienceBar': rng.random() < 0.8,
}
if case['damageCooldown'] and rng.random() < 0.5:
case['healthBlinkTime'] = case['tick'] + rng.randint(1, 20)
if rng.random() < 0.15:
case['vehicleMaxHealth'] = rng.choice([15.0, 30.0, 53.0, 100.0])
case['vehicleHealth'] = round(rng.uniform(0, case['vehicleMaxHealth']), 1)
kind = kinds[n % len(kinds)]
case = KINDS[kind](rng, n)
case['kind'] = kind
out.append(case)
return out
def close(p, q):
if (isinstance(p, float) or isinstance(q, float)) and not isinstance(p, bool) and not isinstance(q, bool):
return abs(p - q) <= 1e-4 * (1 + abs(p))
return p == q
IDENTITY = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
def normal(d):
d = dict(d)
d.setdefault('matrix', IDENTITY)
if d['type'] == 'sprite':
d.setdefault('region', None)
if d['type'] == 'text':
d.setdefault('runs', None)
return d
def same(x, y):
if x.keys() != y.keys():
return False
for k in x:
p, q = x[k], y[k]
if isinstance(p, list) and isinstance(q, list):
if len(p) != len(q) or not all(close(a, b) for a, b in zip(p, q)):
return False
elif not close(p, q):
return False
return True
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--count', type=int, default=600)
parser.add_argument('--detail', type=int, default=3)
parser.add_argument('--kind', action='append', choices=sorted(KINDS), help='only these kinds (repeatable)')
args = parser.parse_args()
kinds = args.kind or list(KINDS)
lock, jars, _ = base.verify_artifacts()
libraries = baking.client_libraries()
build = lab.LOCAL / 'rust-hud-parity'; build.mkdir(parents=True, exist_ok=True)
resources = lab.LOCAL / 'horizon-client' / '26.3'
chosen = cases(args.count)
chosen = cases(args.count, kinds)
inputs = build / 'inputs.jsonl'; inputs.write_text(''.join(json.dumps(c) + '\n' for c in chosen))
classes = build / 'classes'; classes.mkdir(exist_ok=True)
dependencies = os.pathsep.join(map(str, [jars['client'], *libraries]))
@@ -95,27 +110,26 @@ def main():
rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()]
assert len(vanilla) == len(rust)
errors, bad = [], []
totals = {}
for v, r in zip(vanilla, rust):
kind = v['case']['kind']
totals.setdefault(kind, [0, 0])[1] += 1
if 'error' in v:
errors.append(v['error']); continue
a = [{k: x for k, x in d.items() if k != 'color' or d['type'] == 'text'} for d in v['draws']]
for d in a:
if d['type'] == 'sprite':
d.setdefault('region', None)
b = r['draws']
def same(x, y):
if x.keys() != y.keys():
return False
return all(
(all(abs(p - q) <= 1e-4 * (1 + abs(p)) for p, q in zip(x[k], y[k])) if k == 'matrix' else x[k] == y[k]) for k in x)
a = [normal(d) for d in v['draws']]
b = [normal(d) for d in r['draws']]
if len(a) != len(b) or not all(same(x, y) for x, y in zip(a, b)):
first = next((i for i, (x, y) in enumerate(zip(a, b)) if not same(x, y)), min(len(a), len(b)))
bad.append((v['case'], first, a[first:first + 2], b[first:first + 2], len(a), len(b)))
else:
totals[kind][0] += 1
for e in sorted(set(errors))[:5]:
print('ORACLE ERROR', e)
for case, i, a, b, la, lb in bad[:args.detail]:
print('MISMATCH', json.dumps(case))
print(f' at call {i} ({la} vanilla, {lb} Horizon calls)\n vanilla {a}\n horizon {b}')
for kind, (ok, n) in sorted(totals.items()):
print(f' {kind:12} {ok}/{n}')
print(f'{len(vanilla) - len(bad) - len(errors)}/{len(vanilla)} HUD states match; {len(errors)} oracle errors')
if bad or errors:
sys.exit(1)