updated some code

Dieser Commit ist enthalten in:
Sebastian Tobie 2024-12-18 21:59:43 +01:00
Ursprung 5f88cdc3b4
Commit ea6f9170eb

Datei anzeigen

@ -26,18 +26,18 @@ fn new_score(old_score: u32, old: KD, new: KD) -> u32 {
} }
} }
fn sorter(a: &(Kartesian<usize>, KartesianDirection, u32, Kartesian<usize>), b: &(Kartesian<usize>, KartesianDirection, u32, Kartesian<usize>)) -> Ordering { fn sorter(a: &(Kartesian<usize>, KartesianDirection, u32), b: &(Kartesian<usize>, KartesianDirection, u32)) -> Ordering {
a.2.cmp(&b.2).reverse() a.2.cmp(&b.2).reverse()
} }
fn search_end(map: &Map<char>, startpos: Kartesian<usize>, last_dir: KartesianDirection) -> u32 { fn search_end(map: &Map<char>, startpos: Kartesian<usize>, last_dir: KartesianDirection) -> u32 {
let mut posmap: HashMap<Kartesian<usize>, u32> = HashMap::new(); let mut posmap: HashMap<Kartesian<usize>, u32> = HashMap::new();
let mut branches = Vec::with_capacity(200); let mut branches = Vec::with_capacity(200);
branches.push((startpos, last_dir, 0, startpos)); branches.push((startpos, last_dir, 0));
let mut vmap = map.clone(); let mut vmap = map.clone();
let mut best = u32::MAX; let mut best = u32::MAX;
loop { loop {
let (newpos, old_dir, score, oldpos) = match branches.pop() { let (newpos, old_dir, score) = match branches.pop() {
Some(b) => b, Some(b) => b,
None => break, None => break,
}; };
@ -72,7 +72,7 @@ fn search_end(map: &Map<char>, startpos: Kartesian<usize>, last_dir: KartesianDi
}, },
SPACE | START => { SPACE | START => {
let added = new_score(score, old_dir, dir); let added = new_score(score, old_dir, dir);
branches.push((after_move, dir, added, newpos)); branches.push((after_move, dir, added));
}, },
_ => unreachable!(), _ => unreachable!(),
} }