[PR #3690] [MERGED] Fish: random-swim targets match vanilla (water malus 0, FishMoveControl yaw) #5152

Closed
opened 2026-11-03 05:10:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3690
Author: @xFedeT
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/fish-random-swimming-parity


📝 Commits (1)

  • e0fecd8 Fish: swim targets pass the water malus check, and FishMoveControl turns as vanilla

📊 Changes

3 files changed (+29 additions, -1 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+9 -0)
📝 crates/horizon-client/src/mobs/aquatic.rs (+16 -1)
📝 tools/test_mob_ai_parity.py (+4 -0)

📄 Description

🤖 Opened by Federico's AI agent (Claude), not by Federico himself.

Fixes #3631.

What and why

Fish picked random-swim targets differently from vanilla: the random draws drifted within ~20 ticks, and the fish aimed above the water. Root cause, found with the new mob_ai scenarios and a debug dump of each DefaultRandomPos candidate: GoalUtils.hasMalus rejected every candidate in water, because Horizon left PathType.WATER at its default malus 8. Vanilla's WaterAnimal and AgeableWaterCreature constructors set it to 0. Only air candidates were valid, RandomSwimmingGoal found no water block and retried all 10 times (332 draws in a tick instead of 32).

Change

  • mobs/aquatic.rs: set_malus(Water, 0.0) for cod, salmon, tropical fish, pufferfish, tadpole, squid, glow squid and dolphin (WaterAnimal, AgeableWaterCreature).
  • mobs/aquatic.rs fish_move_control: yaw from trig::atan2_degrees like MoveControl, instead of f64::to_degrees (a 2 ulp drift appeared after ~70 ticks).
  • tools/test_mob_ai_parity.py: cod_random_swim, salmon_random_swim, tropical_fish_random_swim (sealed pool, 120 ticks).
  • mob_ai_probe.rs: the fish's goal is named FishSwimGoal, as vanilla's private AbstractFish subclass.

Vanilla reference

WaterAnimal.<init>, AgeableWaterCreature.<init>, RandomSwimmingGoal.getPosition, BehaviorUtils.getRandomSwimmablePos, DefaultRandomPos.getPos, GoalUtils.hasMalus, AbstractFish$FishMoveControl.

Not in this PR

Vanilla's Chicken constructor also sets WATER to 0; Horizon's does not. A separate fix.

Testing

  • Before: 0/3 scenarios match, first divergence at tick 10-20. After: 3/3, 363/363 mob-ticks.
  • python3 tools/parity.py --fresh mob_ai: pass (all scenarios).
  • pr_ready --quick is running; results below once done. Harnesses touching fish elsewhere (living_fluid, squid_client, natural_spawn, finalize_spawn) are left to CI.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3690 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/fish-random-swimming-parity` --- ### 📝 Commits (1) - [`e0fecd8`](https://github.com/horizon-rust/horizon/commit/e0fecd8b8e366b9a15351ca1bc53def2d0f31d53) Fish: swim targets pass the water malus check, and FishMoveControl turns as vanilla ### 📊 Changes **3 files changed** (+29 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+9 -0) 📝 `crates/horizon-client/src/mobs/aquatic.rs` (+16 -1) 📝 `tools/test_mob_ai_parity.py` (+4 -0) </details> ### 📄 Description > 🤖 Opened by Federico's AI agent (Claude), not by Federico himself. Fixes #3631. ## What and why Fish picked random-swim targets differently from vanilla: the random draws drifted within ~20 ticks, and the fish aimed above the water. Root cause, found with the new `mob_ai` scenarios and a debug dump of each `DefaultRandomPos` candidate: `GoalUtils.hasMalus` rejected every candidate in water, because Horizon left `PathType.WATER` at its default malus 8. Vanilla's `WaterAnimal` and `AgeableWaterCreature` constructors set it to 0. Only air candidates were valid, `RandomSwimmingGoal` found no water block and retried all 10 times (332 draws in a tick instead of 32). ## Change - `mobs/aquatic.rs`: `set_malus(Water, 0.0)` for cod, salmon, tropical fish, pufferfish, tadpole, squid, glow squid and dolphin (`WaterAnimal`, `AgeableWaterCreature`). - `mobs/aquatic.rs` `fish_move_control`: yaw from `trig::atan2_degrees` like `MoveControl`, instead of `f64::to_degrees` (a 2 ulp drift appeared after ~70 ticks). - `tools/test_mob_ai_parity.py`: `cod_random_swim`, `salmon_random_swim`, `tropical_fish_random_swim` (sealed pool, 120 ticks). - `mob_ai_probe.rs`: the fish's goal is named `FishSwimGoal`, as vanilla's private `AbstractFish` subclass. ## Vanilla reference `WaterAnimal.<init>`, `AgeableWaterCreature.<init>`, `RandomSwimmingGoal.getPosition`, `BehaviorUtils.getRandomSwimmablePos`, `DefaultRandomPos.getPos`, `GoalUtils.hasMalus`, `AbstractFish$FishMoveControl`. ## Not in this PR Vanilla's `Chicken` constructor also sets `WATER` to 0; Horizon's does not. A separate fix. ## Testing - Before: `0/3` scenarios match, first divergence at tick 10-20. After: `3/3`, `363/363` mob-ticks. - `python3 tools/parity.py --fresh mob_ai`: pass (all scenarios). - `pr_ready --quick` is running; results below once done. Harnesses touching fish elsewhere (`living_fluid`, `squid_client`, `natural_spawn`, `finalize_spawn`) are left to CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:10:36 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5152
No description provided.