I solved 9.2 sometime on Friday.
Right now despite my plans to do more AoC today, I am writing code to write exif / iptc (or whatever) tags into the format that Darktable wants (early attempts had suggested using / for hierarchical tags was fine and now its not.
I also decided to try and hook up my IntelliJ IDE with a local LLM through LM Studio and suddenly I have tons of new GPU driver packages and … am definitely not getting anywhere close to AoC because while the script could be done I am trying to learn to use LM Studio at the same time and…
I think LLMs are really cool. My IDE just downloaded a tiny one specialized on python auto completion … no need for a fat GPU to use that one.
2 Likes
“I’ll just knock up a quick hex coordinate library to support the Talon game software I’ll be writing.”
Half an hour later…
impl Hex {
pub fn offset(&self, dir: i32, d: i32) -> Hex {
// offset [d] hexes in [dir], from E clockwise.
match dir.rem_euclid(6) {
0 => Hex{q: self.q + d, r: self.r},
1 => Hex{q: self.q, r: self.r + d},
2 => Hex{q: self.q - d, r: self.r + d},
3 => Hex{q: self.q - d, r: self.r},
4 => Hex{q: self.q, r: self.r - d},
5 => Hex{q: self.q + d, r: self.r - d},
_ => Hex{q: 0, r: 0}
}
}
pub fn s(&self) -> i32 {
// the secret hidden S coordinate
-self.q - self.r
}
pub fn add(&self, other: &Hex) -> Hex {
// sum of two displacements
Hex{q: self.q + other.q, r: self.r + other.r}
}
pub fn delta(&self, other: &Hex) -> Hex {
// displacement FROM self TO other, other - self
Hex{q: other.q - self.q, r: other.r - self.r}
}
pub fn sub(&self, other: &Hex) -> Hex {
// displacement FROM other TO self, self - other
Hex{q: self.q - other.q, r: self.r - other.r}
}
pub fn range(&self, other: &Hex) -> i32 {
// shortest path distance
let dh = self.delta(other);
( dh.q.abs() +
dh.r.abs() +
dh.s().abs() ) / 2
}
pub fn rotate(&self, steps: i32) -> Hex {
// rotate [steps] 60degree steps clockwise about (0, 0, 0)
let ss = steps.rem_euclid(6);
let mut c = vec![self.q, self.r, self.s()];
if ss.rem_euclid(2) != 0 {
c = vec![-self.q, -self.r, -self.s()];
}
let offset = ss.rem_euclid(3) as usize;
Hex{q: c[offset], r: c[(offset + 1).rem_euclid(3)]}
}
}
5 Likes
And a bit after that, an arc of fire calculator. With tests.
2 Likes