From fafdcc0b0ba5c309df4508561da53fa0f73b9ed1 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 14 Feb 2024 17:27:13 +0100 Subject: [PATCH] change doc --- crates/border-wars/src/hex.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/border-wars/src/hex.rs b/crates/border-wars/src/hex.rs index 492afd9..c775ded 100644 --- a/crates/border-wars/src/hex.rs +++ b/crates/border-wars/src/hex.rs @@ -16,10 +16,10 @@ impl HexNumber for T {} /// [documentation](https://www.redblobgames.com/grids/hexagons/#coordinates). #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct HexPosition { - /// Q coordinate + /// Q coordinate. pub q: T, - /// R coordinate + /// R coordinate. pub r: T, } @@ -46,13 +46,9 @@ impl HexPosition { /// assert_eq!(a.distance_to(&b), 2); /// ``` pub fn distance_to(&self, other: &Self) -> T { - // dx = |x1 - x2| where x = q + // Calculate the difference between the q and r coordinates. let dq = self.q - other.q; - - // dy = |y1 - y2| where y = r let dr = self.r - other.r; - - // dz = |z1 - z2| where z = -q - r let dz = self.q + self.r - other.q - other.r; // Manhattan distance = (abs(dq) + abs(dr) + abs(ds)) / 2