Code-Convention for circuit networks
Posted: Wed May 08, 2024 3:35 pm
Hello everyone!
I hope, this place is the right one for my proposal (don't kill me for my bad english...). for the case you think, another sub forum is more suitable for it, please let me know
A central problem in talking about circuit networks is, that there is no compact way to show someone a complex network. You just can take pictures and explain combinator by combinator, what they are doing and why it is useful to do it this way. For smaller networks, it is no problem to handle this, but the bigger your circuit network will be, the more you need to write to explain what happens in your network.
I would like to introduce an unambiguous and formalized language for circuit networks to allow talking about complex circuits networks in a compact way and i'm interested, if i am the only one who needs something like that. It would be amazing, if this post can be a starting point to create a way to talk about circuit networks more easily, without needing screenshots, long explanations or blueprints and a running factorio instance...
This would be my proposal:
Entity will be named with a prefix based on the type. The first letter should be always a capital letter
As it is usual, that combinators are connected to other entities (otherwise circuit networks would be lame... ), there is a need to find a way to specify, how they are connected.
After defining an entity, you specify the connections in square brackets. The announced connections are separated with a comma.
A connection is defined with a beginning small 'i' (input) or 'o' (output), followed with a small letter for the color of the connected wire.
Example 1:
==> EntityName[Connections](Configuration)
Example, based on Example 2 i mentioned earlier:
C45[ogA10, ogA11](-> SA = 100), A10[igC45, orD20](SA * 2 -> SA), A11[igC45, orD20](SA + 100 -> SB), D20[irA10,irA11,ogOLamp12](SA >= SB -> as SC = 1), OLamp12[igD20](SC = 1 -> Activate)
To be fair, this short explanation is complicated by itself and you need to learn the formalism, but the advantage is you don't need to take screenshots or blueprints to describe your network. And much more important is the fact that you don't need long explanations how you connected the entities with each other and how you configured them. If you think, your circuit network behaves unexpected, you can share your network and other people can simply support answers like "A36 is wrong, you need config ( SH + 14 -> as SA )".
What you are thinking about it?
I hope, this place is the right one for my proposal (don't kill me for my bad english...). for the case you think, another sub forum is more suitable for it, please let me know
A central problem in talking about circuit networks is, that there is no compact way to show someone a complex network. You just can take pictures and explain combinator by combinator, what they are doing and why it is useful to do it this way. For smaller networks, it is no problem to handle this, but the bigger your circuit network will be, the more you need to write to explain what happens in your network.
I would like to introduce an unambiguous and formalized language for circuit networks to allow talking about complex circuits networks in a compact way and i'm interested, if i am the only one who needs something like that. It would be amazing, if this post can be a starting point to create a way to talk about circuit networks more easily, without needing screenshots, long explanations or blueprints and a running factorio instance...
This would be my proposal:
Basic naming rules for entities
- Every entity in a circuit network needs a unique name.
- Entities of the same type should have a similar name.
Entity will be named with a prefix based on the type. The first letter should be always a capital letter
- Constant Combinator -> C
- Arithmetic Combinator -> A
- Decider Combinator -> D
- Other Parts -> ONameOfEntityType (e.g. 'OLamp', 'ORailSignal', etc...)
- A100 (Arithmetic Combinator 100)
- C2 (Constant Combinator 2)
- D34 (Decider Combinator 34)
- OLamp334 (Lamp 334)
As it is usual, that combinators are connected to other entities (otherwise circuit networks would be lame... ), there is a need to find a way to specify, how they are connected.
Basic convention for describing a connection between two entities
- It has to be specified, which wire color is used to connect the two entities
- It has to be specified, if the input was used or the output
- When there are more than one connection, you need to separate them with a speparator like a comma
- for every input-connection you need to specify an output connection of another entity
After defining an entity, you specify the connections in square brackets. The announced connections are separated with a comma.
A connection is defined with a beginning small 'i' (input) or 'o' (output), followed with a small letter for the color of the connected wire.
Example 1:
- A10 [irOMiner23]
Arithmetic Combinator 10 input is connected to Miner 23 via red wire. - OMiner23 [orA10]
Output of miner 23 is connected to Arithmetic Combinator 10 via red wire.
- C45 [ogA10, ogA11]
Output of Constant Combinator 45 is connected to Arithmentic Combinator 10 and Arithmentic Combinator 11 via green wire - A10 [igC45, orD20]
Input of Arithmentic Combinator 10 is connected to Constant Combinator 45 via green wire and output is connected to Decider Combinator 20 via red wire. - A11 [igC45, orD20]
Input of Arithmentic Combinator 11 is connected to Constant Combinator 45 via green wire and output is connected to Decider Combinator 20 via red wire. - D20 [irA10, irA11, ogOLamp12]
input of Decider Combinator 20 is connected to Arithmentic Combinators 10 and 11 via red wire and its output is connected to Lamp 12 via green wire. - OLamp12 [igD20]
input of Lamp 12 is connected to Decider Combinator 20
Basic conventions for describing configuration of an entity
You need to specify a way to easy communicate what is configured in each entity.- Every configuration is described in usual brackets
- Signalnames will start with a capital 'S' and a Name of the type (e.g. "SCrudeOil" or "SG")
- The input and output of an entity is separated with "->". If there is no input or output, the side of configuration stays empty
- If an entity output allows a change of the output signal, it should be called with an 'as' followed by the name of the new signal
- If there are more than one signals may be displayed comma-separated
- Decider Combinators may be expressed as formula
- Arithemtic Combinators may be expressed as formula
- Constant Combinators may be expressed as formula
- Other entitities needs standardization based on the possibilities they supporting
- D667 ( SCrudeOil <= 50000 -> SCrudeOil as SA )
If Signal Crude Oil is lighter or equal 50000, send amount of Crude Oil as Signal A to output - D668 ( SCrudeOil > 100000 -> as SB = 1)
If Signal Crude Oil is greater than 100000, send 1 as Signal B to output. - A23 (SMetalPlates * 4 -> SMetalPlates )
Multiply incoming Signal for Metal Plates with 4 and send this amount as Signal for Metal Plates to output - C89 ( -> SA = 100, SB = 400)
Send 100 as Signal A and 400 as Signal B to output. - OLamp14 ( SA = 1 -> Activate )
Active Lamp 14 if Signal A is equal to 1
Standard Convention to describe an entity with its configuration and connections
Basically defining an entity should follow this syntax==> EntityName[Connections](Configuration)
Example, based on Example 2 i mentioned earlier:
- C45[ogA10, ogA11](-> SA = 100)
Output of Constant Combinator 45 is connected to Arithmentic Combinator 10 and Arithmentic Combinator 11 via green wire. Send Signal A with Value 100 to the output. - A10 [igC45, orD20]( SA * 2 -> SA )
Input of Arithmentic Combinator 10 is connected to Constant Combinator 45 via green wire and output is connected to Decider Combinator 20 via red wire. Multiply Signal A with 2 and send new value as Signal A to output - A11 [igC45, orD20]( SA + 100 -> as SB )
Input of Arithmentic Combinator 11 is connected to Constant Combinator 45 via green wire and output is connected to Decider Combinator 20 via red wire. Add 100 to Signal A and send new value as Signal B to output - D20 [irA10, irA11, ogOLamp12]( SA >= SB -> as SC = 1)
input of Decider Combinator 20 is connected to Arithmentic Combinators 10 and 11 via red wire and its output is connected to Lamp 12 via green wire. If Signal A is greater or equal than Signal B, then send Signal C with value 1 to output. - OLamp12 [igD20]( SC = 1 -> Activate )
input of Lamp 12 is connected to Decider Combinator 20. Activate lamp if Signal C is equal 1.
C45[ogA10, ogA11](-> SA = 100), A10[igC45, orD20](SA * 2 -> SA), A11[igC45, orD20](SA + 100 -> SB), D20[irA10,irA11,ogOLamp12](SA >= SB -> as SC = 1), OLamp12[igD20](SC = 1 -> Activate)
To be fair, this short explanation is complicated by itself and you need to learn the formalism, but the advantage is you don't need to take screenshots or blueprints to describe your network. And much more important is the fact that you don't need long explanations how you connected the entities with each other and how you configured them. If you think, your circuit network behaves unexpected, you can share your network and other people can simply support answers like "A36 is wrong, you need config ( SH + 14 -> as SA )".
What you are thinking about it?