Circuit network design
Posted: Mon Sep 30, 2019 8:10 pm
I want to suggest something about the current circuit network design is unintuitive / inconsistent. My rationale is a little technical, but i think that my main point applies to any audience using logic networks. I'm basing my thoughts off 10ish hours of just playing with networks in Factorio + experience outside of Factorio
I see the current circuit network design as each network instance has its own dictionary of 0+ key -> value pairs. The player can implement custom logic on any network using the three Factorio combinators. These combinators can reference their network in terms of its key -> value pairs. Here are a few restrictions on these key -> value pairs that are relevant to my discussion
All keys must have a non-null value, or they won't be included in the dictionary
0 is treated as a null value
All values must be integers
These properties have some implications
1. This algorithm compresses the 0's out of the network's representation, meaning less overhead for each individual network and less computation for each evaluation of "any", "all", "each" operations. In my thinking, 0's probably form the majority of a Factorio network's unreferenced bloat, caused by reading chest contents
2. 0 as a value in a key -> value pair is always as a null value / missing key rather than as the integer value less than 1 and greater than -1. As an example, for a network with no coal signal, checking network[coal] == 0 implicitly returns false as the 0 on the right represents an integer and the one on the left represents null. The rationale for why this is happening will not be clear for some players
3. A player who wants to reference the integer value 0 in a key->value pair is going to need to jump through hoops
Here's a common example: say I want to check when a chest runs out of entity X, ie its value equals zero. The easiest way to do this with the current implementation is to: read the chest's contents, increase the value of the key(s) that I want to check by 1, and then check that the sum equals 1. While possible, mapping between integer 0 and null 0 poses a repetitive problem for any larger scale abstraction that needs to use both representations of 0
Overall, I think the current implementation conflates too many goals. Aspects of what, to me, is mainly a performance optimization in a way have become the player's problem. Not only do players lack the tools to effectively approach this problem, but, more importantly, they likely have no interest in this specific problem at all (they just wanted to check if the chest was empty!!)
I think the player would be better off having access to 0 as an integer and null as a seperate special value and/or key. While initially I thought I liked the simplicity of dealing with non-nullable ints, now i see that they're still nullable, its just that null is confusingly disguised as 0. I think spelling null out as a special value/key is exclusively more clear for the uninformed user than repurposing 0. Also, you'd probably just label null in the UI as "No signal" or something, and I think that's a pretty intuitive starting point for any audience
This alternative design would need additional development to achieve similar levels of performance as the current. Without knowing more about Factorio's needs for logic network performance and reliability, i'm a little too far out into the unknown to contribute... I don't even know if Factorio's circuit network update implementation is scan based or event based...
I see the current circuit network design as each network instance has its own dictionary of 0+ key -> value pairs. The player can implement custom logic on any network using the three Factorio combinators. These combinators can reference their network in terms of its key -> value pairs. Here are a few restrictions on these key -> value pairs that are relevant to my discussion
All keys must have a non-null value, or they won't be included in the dictionary
0 is treated as a null value
All values must be integers
These properties have some implications
1. This algorithm compresses the 0's out of the network's representation, meaning less overhead for each individual network and less computation for each evaluation of "any", "all", "each" operations. In my thinking, 0's probably form the majority of a Factorio network's unreferenced bloat, caused by reading chest contents
2. 0 as a value in a key -> value pair is always as a null value / missing key rather than as the integer value less than 1 and greater than -1. As an example, for a network with no coal signal, checking network[coal] == 0 implicitly returns false as the 0 on the right represents an integer and the one on the left represents null. The rationale for why this is happening will not be clear for some players
3. A player who wants to reference the integer value 0 in a key->value pair is going to need to jump through hoops
Here's a common example: say I want to check when a chest runs out of entity X, ie its value equals zero. The easiest way to do this with the current implementation is to: read the chest's contents, increase the value of the key(s) that I want to check by 1, and then check that the sum equals 1. While possible, mapping between integer 0 and null 0 poses a repetitive problem for any larger scale abstraction that needs to use both representations of 0
Overall, I think the current implementation conflates too many goals. Aspects of what, to me, is mainly a performance optimization in a way have become the player's problem. Not only do players lack the tools to effectively approach this problem, but, more importantly, they likely have no interest in this specific problem at all (they just wanted to check if the chest was empty!!)
I think the player would be better off having access to 0 as an integer and null as a seperate special value and/or key. While initially I thought I liked the simplicity of dealing with non-nullable ints, now i see that they're still nullable, its just that null is confusingly disguised as 0. I think spelling null out as a special value/key is exclusively more clear for the uninformed user than repurposing 0. Also, you'd probably just label null in the UI as "No signal" or something, and I think that's a pretty intuitive starting point for any audience
This alternative design would need additional development to achieve similar levels of performance as the current. Without knowing more about Factorio's needs for logic network performance and reliability, i'm a little too far out into the unknown to contribute... I don't even know if Factorio's circuit network update implementation is scan based or event based...