Parameterize priority queue
This commit is contained in:
parent
6f74f1345e
commit
ffe51bede9
14 changed files with 276 additions and 183 deletions
|
|
@ -1,7 +1,10 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use factorio_core::prelude::Position;
|
||||
use factorio_core::prelude::{Direction, Position};
|
||||
use factorio_graph::{
|
||||
priority_queue::binary_heap::FastBinaryHeap, wheighted_graph::shortest_path::QueueObject,
|
||||
};
|
||||
use factorio_layout::{Layouter, valid_layout::ValidLayout};
|
||||
use factorio_pathfinding::belt_finding::ConflictAvoidance;
|
||||
use rand::{SeedableRng, rngs::SmallRng};
|
||||
|
|
@ -32,6 +35,9 @@ fn main() {
|
|||
|
||||
let p = ConflictAvoidance {
|
||||
timeout: Some(std::time::Duration::from_millis(5)),
|
||||
priority_queue: std::marker::PhantomData::<
|
||||
FastBinaryHeap<QueueObject<(Position, Direction)>>,
|
||||
>,
|
||||
};
|
||||
|
||||
let mut rng = SmallRng::seed_from_u64(args.seed);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ use factorio_core::{
|
|||
prelude::*,
|
||||
visualize::{Color, Symbol, Visualization, Visualize, image_grid},
|
||||
};
|
||||
use factorio_graph::priority_queue::binary_heap::FastBinaryHeap;
|
||||
use factorio_pathfinding::belt_finding::{self, conflict_avoidance::ConflictAvoidance};
|
||||
use rand::{
|
||||
Rng,
|
||||
seq::IndexedRandom,
|
||||
};
|
||||
use rand::{Rng, seq::IndexedRandom};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{sync::atomic::AtomicU32, time::Instant};
|
||||
|
||||
|
|
@ -241,7 +239,7 @@ impl<'a> PathLayout<'a> {
|
|||
pub fn new(layout: Layout<'a>) -> Option<PathLayout<'a>> {
|
||||
let mut p = beltfinding_problem_from_layout(&layout);
|
||||
|
||||
if !p.find_path() {
|
||||
if !p.find_path::<FastBinaryHeap<_>>() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue