Finish subfactory interface

This commit is contained in:
hal8174 2025-04-17 18:50:52 +02:00
parent 82394cc342
commit ff8795cea5
11 changed files with 537 additions and 310 deletions

View file

@ -1,24 +1,29 @@
subfactories:
- !SubFactory
recipe: military-science-pack
machines: 40
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: military-science-pack
num_machines: 40
machine: assembling-machine-3
- !SubFactory
recipe: piercing-rounds-magazine
machines: 12
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: piercing-rounds-magazine
num_machines: 12
machine: assembling-machine-3
- !SubFactory
recipe: firearm-magazine
machines: 4
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: firearm-magazine
num_machines: 4
machine: assembling-machine-3
- !SubFactory
recipe: grenade
machines: 32
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: grenade
num_machines: 32
machine: assembling-machine-3
- !SubFactory
recipe: stone-wall
machines: 4
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: stone-wall
num_machines: 4
machine: assembling-machine-3
- !ExternalConnection
factory_connections:
- item: military-science-pack

View file

@ -1,44 +1,54 @@
subfactories:
- !SubFactory
recipe: chemical-science-pack
machines: 96
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: chemical-science-pack
num_machines: 96
machine: assembling-machine-3
- !SubFactory
recipe: engine-unit
machines: 80
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: engine-unit
num_machines: 80
machine: assembling-machine-3
- !SubFactory
recipe: iron-gear-wheel
machines: 4
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: iron-gear-wheel
num_machines: 4
machine: assembling-machine-3
- !SubFactory
recipe: pipe
machines: 8
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: pipe
num_machines: 8
machine: assembling-machine-3
- !SubFactory
recipe: advanced-circuit
machines: 72
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: advanced-circuit
num_machines: 72
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 10
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 10
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 10
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 10
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 10
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 10
machine: assembling-machine-3
- !ExternalConnection
- !Splitter
- !Splitter

View file

@ -1,57 +1,69 @@
subfactories:
- !SubFactory
recipe: chemical-science-pack
machines: 96
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: chemical-science-pack
num_machines: 96
machine: assembling-machine-3
- !SubFactory
recipe: engine-unit
machines: 80
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: engine-unit
num_machines: 80
machine: assembling-machine-3
- !SubFactory
recipe: iron-gear-wheel
machines: 4
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: iron-gear-wheel
num_machines: 4
machine: assembling-machine-3
- !SubFactory
recipe: pipe
machines: 8
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: pipe
num_machines: 8
machine: assembling-machine-3
- !SubFactory
recipe: advanced-circuit
machines: 72
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: advanced-circuit
num_machines: 72
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 10
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 10
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 10
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 10
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 10
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 10
machine: assembling-machine-3
- !ExternalConnection
- !Distributor
- !Distributor
- !Distributor
- !SubFactory
recipe: copper-plate
machines: 64
machine: electric-furnace
subfactory: !DoubleAssemblingLine
recipe: copper-plate
num_machines: 64
machine: electric-furnace
- !Distributor
- !SubFactory
recipe: copper-plate
machines: 48
machine: electric-furnace
subfactory: !DoubleAssemblingLine
recipe: copper-plate
num_machines: 48
machine: electric-furnace
factory_connections:
- item: chemical-science-pack
amount: 10

View file

@ -1,25 +1,30 @@
subfactories:
- !SubFactory
recipe: iron-gear-wheel
machines: 2
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: iron-gear-wheel
num_machines: 2
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 9
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 9
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 6
machine: assembling-machine-3
- !Splitter
- !SubFactory
recipe: inserter
machines: 2
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: inserter
num_machines: 2
machine: assembling-machine-3
- !SubFactory
recipe: fast-inserter
machines: 2
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: fast-inserter
num_machines: 2
machine: assembling-machine-3
- !SideLoader
- !ExternalConnection
- !SideLoader

View file

@ -1,28 +1,34 @@
subfactories:
- !SubFactory
recipe: logistic-science-pack
machines: 48
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: logistic-science-pack
num_machines: 48
machine: assembling-machine-3
- !SubFactory
recipe: inserter
machines: 4
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: inserter
num_machines: 4
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 4
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 4
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: transport-belt
machines: 2
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: transport-belt
num_machines: 2
machine: assembling-machine-3
- !SubFactory
recipe: iron-gear-wheel
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: iron-gear-wheel
num_machines: 6
machine: assembling-machine-3
- !ExternalConnection
- !Splitter
factory_connections:

View file

@ -1,20 +1,24 @@
subfactories:
- !SubFactory
recipe: iron-gear-wheel
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: iron-gear-wheel
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: copper-cable
machines: 9
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: copper-cable
num_machines: 9
machine: assembling-machine-3
- !SubFactory
recipe: electronic-circuit
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: electronic-circuit
num_machines: 6
machine: assembling-machine-3
- !SubFactory
recipe: inserter
machines: 6
machine: assembling-machine-3
subfactory: !DoubleAssemblingLine
recipe: inserter
num_machines: 6
machine: assembling-machine-3
- !ExternalConnection
factory_connections:
- item: iron-gear-wheel

View file

@ -10,7 +10,7 @@ struct Args {
json: bool,
assembly_machines: usize,
machine: String,
recipe: String,
recipe: Option<String>,
output_belt: Beltspeed,
input_belt: Vec<Beltspeed>,
}

View file

@ -1,6 +1,6 @@
use crate::{
multistation::{StationSpec, multistation},
subfactory::assembling_line::assembly_line_2_input,
subfactory::{BeltConnection, SubFactory, assembling_line::assembly_line_2_input},
};
use factorio_blueprint::abstraction::{Blueprint, Entity};
use factorio_core::{beltoptions::Beltspeed, prelude::*, visualize::Visualize};
@ -18,11 +18,7 @@ pub struct FactoryGraph {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum Building {
SubFactory {
recipe: String,
machines: usize,
machine: String,
},
SubFactory { subfactory: SubFactory },
ExternalConnection,
Splitter,
SideLoader,
@ -65,7 +61,7 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
let mut station_spec = Vec::new();
for (i, b) in factory_graph.subfactories.iter().enumerate() {
let mut input_connections = factory_graph
let input_connections = factory_graph
.factory_connections
.iter()
.enumerate()
@ -82,84 +78,115 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
let block_index = blocks.len();
match b {
Building::SubFactory {
recipe,
machines,
machine,
} => {
// assert_eq!(machine, "assembly-machine-3");
assert_eq!(output_connections.len(), 1);
assert!(input_connections.len() <= 3);
let output_connection = output_connections.first().unwrap();
let intermediate_output_connection = HashMap::from([(
output_connection.0,
IntermediateConnectionEntry {
block: Some(block_index),
interface: 0,
},
)]);
Building::SubFactory { subfactory } => {
let inputs = input_connections
.iter()
.map(|(_, f)| (f.item.as_str(), f.amount))
.fold(HashMap::new(), |mut h, (s, a)| {
match h.entry(s) {
std::collections::hash_map::Entry::Occupied(mut occupied_entry) => {
*occupied_entry.get_mut() += a;
}
std::collections::hash_map::Entry::Vacant(vacant_entry) => {
vacant_entry.insert(a);
}
}
h
})
.into_iter()
.collect::<Vec<_>>();
input_connections.sort_by(|a, b| b.1.amount.total_cmp(&a.1.amount));
let (input_belt1, input_belt2, addition_blocks) = if let Some(
&[
(connection_id0, c0),
(connection_id1, c1),
(connection_id2, c2),
],
) =
input_connections.first_chunk()
{
let c0_bigger = c0.amount > c1.amount + c2.amount;
intermediate_connections.push(IntermediateConnection {
input: HashMap::from([
(
connection_id0,
let outputs = output_connections
.iter()
.map(|(_, f)| (f.item.as_str(), f.amount))
.fold(HashMap::new(), |mut h, (s, a)| {
match h.entry(s) {
std::collections::hash_map::Entry::Occupied(mut occupied_entry) => {
*occupied_entry.get_mut() += a;
}
std::collections::hash_map::Entry::Vacant(vacant_entry) => {
vacant_entry.insert(a);
}
}
h
})
.into_iter()
.collect::<Vec<_>>();
let (b, m, input_belts, output_belts) =
subfactory.get_subfactory(&inputs, &outputs);
assert!(output_belts.len() == 1);
assert!(output_connections.len() == 1);
assert!(output_belts[0] == BeltConnection::Full(outputs[0]));
blueprints.push(b);
blocks.push(m);
let mut intermediate_input_connections = HashMap::new();
for (interface, input_belt) in input_belts.iter().enumerate() {
match input_belt {
BeltConnection::Full((s, _a)) => {
let input_connection = input_connections
.iter()
.find(|(_, f)| f.item == *s)
.unwrap();
intermediate_input_connections.insert(
input_connection.0,
IntermediateConnectionEntry {
block: Some(block_index),
interface: if c0_bigger { 1 } else { 0 },
interface,
},
),
(
connection_id1,
);
}
BeltConnection::Split { left, right } => {
let beltspeed =
Beltspeed::from_items_per_second(2.0 * f64::max(left.1, right.1));
connections.push(Connection {
startblock: Some(blocks.len()),
startpoint: 0,
endblock: Some(block_index),
endpoint: interface,
lanes: 1,
beltspeed,
});
let input_connection_left = input_connections
.iter()
.find(|(_, f)| f.item == *left.0)
.unwrap();
intermediate_input_connections.insert(
input_connection_left.0,
IntermediateConnectionEntry {
block: Some(block_index + 1),
block: Some(blocks.len()),
interface: 0,
},
),
(
connection_id2,
);
let input_connection_right = input_connections
.iter()
.find(|(_, f)| f.item == *right.0)
.unwrap();
intermediate_input_connections.insert(
input_connection_right.0,
IntermediateConnectionEntry {
block: Some(block_index + 1),
block: Some(blocks.len()),
interface: 1,
},
),
]),
output: intermediate_output_connection,
});
);
let beltspeed =
Beltspeed::from_items_per_second(2.0 * f64::max(c1.amount, c2.amount));
let mut b = Blueprint::new();
b.add_entity(Entity::new_belt(
beltspeed,
Position::new(1, 1),
Direction::Up,
));
connections.push(Connection {
startblock: Some(block_index + 1),
startpoint: 0,
endblock: Some(block_index),
endpoint: if c0_bigger { 0 } else { 1 },
lanes: 1,
beltspeed,
});
let mut b = Blueprint::new();
b.add_entity(Entity::new_belt(
beltspeed,
Position::new(1, 1),
Direction::Up,
));
(
Beltspeed::from_items_per_second(c0.amount),
Some(beltspeed),
vec![(
MacroBlock {
blueprints.push(b);
blocks.push(MacroBlock {
size: Position::new(1, 1),
input: vec![
Interface {
@ -175,87 +202,191 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
offset: Position::new(0, 0),
dir: Direction::Up,
}],
},
b,
)],
)
} else if let Some(&[(connection_id0, c0), (connection_id1, c1)]) =
input_connections.first_chunk()
{
intermediate_connections.push(IntermediateConnection {
input: HashMap::from([
(
connection_id0,
IntermediateConnectionEntry {
block: Some(block_index),
interface: 0,
},
),
(
connection_id1,
IntermediateConnectionEntry {
block: Some(block_index),
interface: 1,
},
),
]),
output: intermediate_output_connection,
});
(
Beltspeed::from_items_per_second(c0.amount),
Some(Beltspeed::from_items_per_second(c1.amount)),
vec![],
)
} else if let Some(&[(connection_id, c)]) = input_connections.first_chunk() {
intermediate_connections.push(IntermediateConnection {
input: HashMap::from([(
connection_id,
IntermediateConnectionEntry {
block: Some(block_index),
interface: 0,
},
)]),
output: intermediate_output_connection,
});
(Beltspeed::from_items_per_second(c.amount), None, vec![])
} else {
unreachable!()
};
});
}
}
}
let (b, size, y_output, y_inputs) = assembly_line_2_input(
*machines,
machine,
recipe,
input_belt1,
input_belt2,
Beltspeed::from_items_per_second(
output_connections
.first()
.map(|&(_, c)| c.amount)
.unwrap_or(1.0),
),
);
blueprints.push(b);
blocks.push(MacroBlock {
size,
input: y_inputs
.iter()
.map(|&y| Interface {
offset: Position::new(0, y),
dir: Direction::Right,
})
.collect(),
output: vec![Interface {
offset: Position::new(0, y_output),
dir: Direction::Left,
}],
intermediate_connections.push(IntermediateConnection {
input: intermediate_input_connections,
output: HashMap::from([(
output_connections[0].0,
IntermediateConnectionEntry {
block: Some(block_index),
interface: 0,
},
)]),
});
for (mb, b) in addition_blocks {
blueprints.push(b);
blocks.push(mb);
}
// // assert_eq!(machine, "assembly-machine-3");
// assert_eq!(output_connections.len(), 1);
// assert!(input_connections.len() <= 3);
// let output_connection = output_connections.first().unwrap();
// let intermediate_output_connection = HashMap::from([(
// output_connection.0,
// IntermediateConnectionEntry {
// block: Some(block_index),
// interface: 0,
// },
// )]);
// input_connections.sort_by(|a, b| b.1.amount.total_cmp(&a.1.amount));
// let (input_belt1, input_belt2, addition_blocks) = if let Some(
// &[
// (connection_id0, c0),
// (connection_id1, c1),
// (connection_id2, c2),
// ],
// ) =
// input_connections.first_chunk()
// {
// let c0_bigger = c0.amount > c1.amount + c2.amount;
// intermediate_connections.push(IntermediateConnection {
// input: HashMap::from([
// (
// connection_id0,
// IntermediateConnectionEntry {
// block: Some(block_index),
// interface: if c0_bigger { 1 } else { 0 },
// },
// ),
// (
// connection_id1,
// IntermediateConnectionEntry {
// block: Some(block_index + 1),
// interface: 0,
// },
// ),
// (
// connection_id2,
// IntermediateConnectionEntry {
// block: Some(block_index + 1),
// interface: 1,
// },
// ),
// ]),
// output: intermediate_output_connection,
// });
// let beltspeed =
// Beltspeed::from_items_per_second(2.0 * f64::max(c1.amount, c2.amount));
// connections.push(Connection {
// startblock: Some(block_index + 1),
// startpoint: 0,
// endblock: Some(block_index),
// endpoint: if c0_bigger { 0 } else { 1 },
// lanes: 1,
// beltspeed,
// });
// let mut b = Blueprint::new();
// b.add_entity(Entity::new_belt(
// beltspeed,
// Position::new(1, 1),
// Direction::Up,
// ));
// (
// Beltspeed::from_items_per_second(c0.amount),
// Some(beltspeed),
// vec![(
// MacroBlock {
// size: Position::new(1, 1),
// input: vec![
// Interface {
// offset: Position::new(0, 0),
// dir: Direction::Right,
// },
// Interface {
// offset: Position::new(0, 0),
// dir: Direction::Left,
// },
// ],
// output: vec![Interface {
// offset: Position::new(0, 0),
// dir: Direction::Up,
// }],
// },
// b,
// )],
// )
// } else if let Some(&[(connection_id0, c0), (connection_id1, c1)]) =
// input_connections.first_chunk()
// {
// intermediate_connections.push(IntermediateConnection {
// input: HashMap::from([
// (
// connection_id0,
// IntermediateConnectionEntry {
// block: Some(block_index),
// interface: 0,
// },
// ),
// (
// connection_id1,
// IntermediateConnectionEntry {
// block: Some(block_index),
// interface: 1,
// },
// ),
// ]),
// output: intermediate_output_connection,
// });
// (
// Beltspeed::from_items_per_second(c0.amount),
// Some(Beltspeed::from_items_per_second(c1.amount)),
// vec![],
// )
// } else if let Some(&[(connection_id, c)]) = input_connections.first_chunk() {
// intermediate_connections.push(IntermediateConnection {
// input: HashMap::from([(
// connection_id,
// IntermediateConnectionEntry {
// block: Some(block_index),
// interface: 0,
// },
// )]),
// output: intermediate_output_connection,
// });
// (Beltspeed::from_items_per_second(c.amount), None, vec![])
// } else {
// unreachable!()
// };
// let (b, size, y_output, y_inputs) = assembly_line_2_input(
// *machines,
// machine,
// Some(recipe),
// input_belt1,
// input_belt2,
// Beltspeed::from_items_per_second(
// output_connections
// .first()
// .map(|&(_, c)| c.amount)
// .unwrap_or(1.0),
// ),
// );
// blueprints.push(b);
// blocks.push(MacroBlock {
// size,
// input: y_inputs
// .iter()
// .map(|&y| Interface {
// offset: Position::new(0, y),
// dir: Direction::Right,
// })
// .collect(),
// output: vec![Interface {
// offset: Position::new(0, y_output),
// dir: Direction::Left,
// }],
// });
// for (mb, b) in addition_blocks {
// blueprints.push(b);
// blocks.push(mb);
// }
}
Building::ExternalConnection => {
// let step = 1;

View file

@ -1,9 +1,15 @@
use assembling_line::assembly_line_2_input;
use factorio_blueprint::abstraction::Blueprint;
use factorio_core::beltoptions::{Beltspeed, Belttype};
use factorio_layout::MacroBlock;
use factorio_core::{
beltoptions::{Beltspeed, Belttype},
prelude::{Direction, Position},
};
use factorio_layout::{Interface, MacroBlock};
use serde::{Deserialize, Serialize};
pub mod assembling_line;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum SubFactory {
AssemblingLine {
num_machines: usize,
@ -17,21 +23,25 @@ pub enum SubFactory {
},
}
enum BeltConnection {
Full(String),
Split { left: String, right: String },
#[derive(Debug, Clone, PartialEq)]
pub enum BeltConnection<'a> {
Full((&'a str, f64)),
Split {
left: (&'a str, f64),
right: (&'a str, f64),
},
}
impl SubFactory {
fn get_subfactory(
pub fn get_subfactory<'a>(
&self,
inputs: &[(&str, f64)],
outputs: &[(&str, f64)],
inputs: &[(&'a str, f64)],
outputs: &[(&'a str, f64)],
) -> (
Blueprint,
MacroBlock,
Vec<BeltConnection>,
Vec<BeltConnection>,
Vec<BeltConnection<'a>>,
Vec<BeltConnection<'a>>,
) {
match self {
SubFactory::AssemblingLine {
@ -61,13 +71,13 @@ impl SubFactory {
{
(
BeltConnection::Split {
left: input1.to_owned(),
right: input2.to_owned(),
left: (input1, amount1),
right: (input2, amount2),
},
Beltspeed::from_items_per_second(2.0 * f64::max(amount1, amount2)),
BeltConnection::Split {
left: input3.to_owned(),
right: input4.to_owned(),
left: (input3, amount3),
right: (input4, amount4),
},
Beltspeed::from_items_per_second(2.0 * f64::max(amount3, amount4)),
)
@ -75,11 +85,11 @@ impl SubFactory {
inputs.first_chunk()
{
(
BeltConnection::Full(input1.to_owned()),
BeltConnection::Full((input1, amount1)),
Beltspeed::from_items_per_second(amount1),
BeltConnection::Split {
left: input2.to_owned(),
right: input3.to_owned(),
left: (input2, amount2),
right: (input3, amount3),
},
Beltspeed::from_items_per_second(2.0 * f64::max(amount2, amount3)),
)
@ -87,27 +97,71 @@ impl SubFactory {
inputs.first_chunk()
{
(
BeltConnection::Full(input1.to_owned()),
BeltConnection::Full((input1, amount1)),
Beltspeed::from_items_per_second(amount1),
BeltConnection::Full(input2.to_owned()),
BeltConnection::Full((input2, amount2)),
Beltspeed::from_items_per_second(amount2),
)
} else {
unreachable!()
};
let (b, size, y_output, y_inputs) = assembly_line_2_input(
*num_machines,
machine,
recipe.as_ref(),
belttype1,
Some(belttype2),
Beltspeed::from_items_per_second(outputs[0].1),
);
(
todo!(),
todo!(),
b,
MacroBlock {
size,
input: y_inputs
.iter()
.map(|&y| Interface {
offset: Position::new(0, y),
dir: Direction::Right,
})
.collect(),
output: vec![Interface {
offset: Position::new(0, y_output),
dir: Direction::Left,
}],
},
vec![input1, input2],
vec![BeltConnection::Full(outputs[0].0.to_owned())],
vec![BeltConnection::Full(outputs[0])],
)
} else {
let (b, size, y_output, y_inputs) = assembly_line_2_input(
*num_machines,
machine,
recipe.as_ref(),
Beltspeed::from_items_per_second(inputs[0].1),
None,
Beltspeed::from_items_per_second(outputs[0].1),
);
(
todo!(),
todo!(),
vec![BeltConnection::Full(inputs[0].0.to_owned())],
vec![BeltConnection::Full(outputs[0].0.to_owned())],
b,
MacroBlock {
size,
input: y_inputs
.iter()
.map(|&y| Interface {
offset: Position::new(0, y),
dir: Direction::Right,
})
.collect(),
output: vec![Interface {
offset: Position::new(0, y_output),
dir: Direction::Left,
}],
},
vec![BeltConnection::Full(inputs[0])],
vec![BeltConnection::Full(outputs[0])],
)
}
}

View file

@ -10,7 +10,7 @@ AAABBBCCC
pub fn assembly_line(
assembly_machines: usize,
machine: impl AsRef<str>,
recipe: impl AsRef<str>,
recipe: Option<impl AsRef<str>>,
) -> Blueprint {
let mut blueprint = Blueprint::new();
let mut last = None;
@ -228,7 +228,7 @@ pub fn assembly_line(
pub fn assembly_line_2_input(
assembly_machines: usize,
machine: impl AsRef<str>,
recipe: impl AsRef<str>,
recipe: Option<impl AsRef<str>>,
input_belt1: Beltspeed,
input_belt2: Option<Beltspeed>,
output_belt: Beltspeed,