Add connect output belt to station

This commit is contained in:
hal8174 2025-01-26 15:58:58 +01:00
parent aabd9486e0
commit 1af9712bcb
4 changed files with 435 additions and 139 deletions

View file

@ -1,13 +1,27 @@
use factorio_blueprint::{BlueprintString, encode};
use factorio_blueprint_generator::balancer::{generate_4_lane_balancer, generate_4_lane_balancer2};
use factorio_blueprint::{BlueprintBook, BlueprintBookEntry, BlueprintString, encode};
use factorio_blueprint_generator::balancer::{binary_balancer, generate_4_lane_balancer};
fn main() {
let b = BlueprintString::Blueprint(generate_4_lane_balancer());
let b2 = BlueprintString::Blueprint(generate_4_lane_balancer2());
let mut v = Vec::new();
for i in 0..3 {
let lanes = 1 << i;
let (_, b) = binary_balancer(lanes, factorio_core::beltoptions::Beltspeed::Normal);
v.push(BlueprintBookEntry::new(
BlueprintString::Blueprint(b.to_blueprint()),
i + 1,
));
}
let b = BlueprintString::BlueprintBook(
BlueprintBook::builder()
.blueprints(v)
.active_index(1)
.build(),
);
println!("{}", serde_json::to_string_pretty(&b).unwrap());
println!("{}", serde_json::to_string_pretty(&b2).unwrap());
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
println!("{}", encode(&serde_json::to_string(&b2).unwrap()));
}

View file

@ -12,63 +12,77 @@ struct Args {
fn main() {
let args = Args::parse();
// let stations: Vec<_> = (0..2)
// .map(|_| StationSpec {
// locomotives: 1,
// wagons: 2,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 2,
// })
// .collect();
let stations: Vec<_> = [false, true]
.into_iter()
.flat_map(|load| {
[
Beltspeed::Normal,
Beltspeed::Fast,
Beltspeed::Express,
Beltspeed::Turbo,
]
.into_iter()
.flat_map(move |beltspeed| {
(0..6).flat_map(move |i| {
(0..=i).map(move |j| StationSpec {
locomotives: 1,
wagons: 1 << i,
load,
beltspeed,
lanes: 1 << j,
})
})
})
})
.collect();
let b = BlueprintString::Blueprint(
multistation(
// &stations,
&[
StationSpec {
locomotives: 2,
wagons: 4,
load: false,
beltspeed: Beltspeed::Normal,
lanes: 4,
},
StationSpec {
locomotives: 3,
wagons: 8,
load: false,
beltspeed: Beltspeed::Turbo,
lanes: 8,
},
StationSpec {
locomotives: 3,
wagons: 8,
load: false,
beltspeed: Beltspeed::Turbo,
lanes: 4,
},
StationSpec {
locomotives: 3,
wagons: 8,
load: false,
beltspeed: Beltspeed::Turbo,
lanes: 2,
},
StationSpec {
locomotives: 3,
wagons: 8,
load: false,
beltspeed: Beltspeed::Turbo,
lanes: 1,
},
StationSpec {
locomotives: 1,
wagons: 1,
load: false,
beltspeed: Beltspeed::Turbo,
lanes: 1,
},
],
&stations,
// &[
// StationSpec {
// locomotives: 2,
// wagons: 4,
// load: false,
// beltspeed: Beltspeed::Normal,
// lanes: 4,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 8,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 4,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 2,
// },
// StationSpec {
// locomotives: 3,
// wagons: 8,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 1,
// },
// StationSpec {
// locomotives: 1,
// wagons: 1,
// load: false,
// beltspeed: Beltspeed::Turbo,
// lanes: 1,
// },
// ],
8,
)
.to_blueprint(),