Add multistation to factory

This commit is contained in:
hal8174 2025-03-01 22:31:35 +01:00
parent 41a528a49c
commit 5f5fe0c149
8 changed files with 98 additions and 46 deletions

View file

@ -1,16 +1,16 @@
use crate::examples::HashMapMap;
use crate::graph::wheighted_graph::shortest_path::a_star;
use crate::graph::wheighted_graph::WheightedGraph;
use crate::misc::Map;
use crate::priority_queue::binary_heap::FastBinaryHeap;
use crate::Connection;
use crate::Map as _;
use crate::SinglePathInput;
use crate::SinglePathfinder;
use crate::examples::HashMapMap;
use crate::graph::wheighted_graph::WheightedGraph;
use crate::graph::wheighted_graph::shortest_path::a_star;
use crate::misc::Map;
use crate::priority_queue::binary_heap::FastBinaryHeap;
use factorio_core::{prelude::*, visualize::Visualize};
use serde::{Deserialize, Serialize};
use tracing::span;
use tracing::Level;
use tracing::span;
pub mod brute_force;
@ -119,8 +119,8 @@ impl Problem {
}
for (i, path) in self.path.iter().enumerate() {
if i != without {
for p in path {
if i != without && !path.is_empty() {
for p in &path[1..] {
let weight = 1000.0;
let x = p.0.x as usize;
let y = p.0.y as usize;
@ -238,8 +238,8 @@ impl WheightedGraph for MapInternal<'_> {
let penalty = self.map.get(next.x as usize, next.y as usize).weight;
match num {
0 => Some(((next, node.1), 1.5 + penalty)),
1 => Some(((next, node.1.counter_clockwise()), 1.5 + penalty)),
2 => Some(((next, node.1.clockwise()), 1.5 + penalty)),
1 => Some(((next, node.1.counter_clockwise()), 2.0 + penalty)),
2 => Some(((next, node.1.clockwise()), 2.0 + penalty)),
_ => {
let mut count = 2;
for l in 2..=6 {