Thoughts about circuit network (while I'm just on it)

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by Blackence »

I love DerivePi's illustration of the circuit network ideas! Another "incredible" from me :)

I'd love to be able to play around with something like that. I'm afraid our chances might not be too good though, let's see. Maybe if the mod API allows some cable management, some parts can be modded already? I guess adding arbitrary cable connection options is not yet possible. Maybe by somehow abusing a separate smart chest/inserter based entity for each cable connection slot of a "module/gate/…".

Grouping a few of these gates into a "black box" like a blueprint (and calling it an integrated circuit :D) would be nice. That user-created black box should have a small footprint when being placed, like 1x1 tiles, even though the "original design" where all the gates are placed manually used 100x100 tiles for a somewhat complex circuit design. :lol: I mean, 1x1 tile is still the size of a human. Look at how small chips on this planet are. Of course, manufacturing an integrated circuit should be expensive. Lots of processing units and also expensive "assembly machines" for ICs. If there's one issue in end game, then it's a lack of ressource sinks.
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

+1
While I consider "the microchip idea" silly+cheaty in minecraft (no, you can't go over the 8x8 pixels on the block without mangling the universe),
the same concept does sound valid and frequently-useful for factorio.

Also you seem to agree with me that circuit might be much easier to compose/prototype/wire while spread over a meadow,
where each has only a smallish configuration gui (instead of a giang gui if everything was to be configured there)

PS: I don't see a reason for SSilk's "data teleporatation module" to be fitted on such microchip by default.
It should be manufactured and paid for separately just like the rest of the modules/gates.
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

Can mods create and remove ccnet/power wiring already?
If so, then creation of multi-cable trunks might be possible...
Just create ghost poles behind the real poles and wire them along the real poles.
That gives extra connections for bypassing the 2-CCnets-per-pole limit.
If the auxiliary poles are offset by a tiny bit, then all the connection would appear visually thicker too :)
Making those auxiliary poles smaller reduces a chance of them being hurt instead of the real pole.

EDIT: Oh, I see what you're talking about.. it's "relaying signals from one cable to another"
For reading a cable.. using smart inserters might work... but would't there be too many / require more ticks for a full readout?
For writing a fake smart chest might do.

Would be possible to establish a stable bi-directional connection at all?
Without causing oscillations on the network / desyncs?
Even when there are more of such "connections" on one supernetwork?

I think connecting cables (1) and (2) bi-directionally could be done like this:

Code: Select all

in1 = read(inserters1)
in2 = read(inserters2)
out1 = read(chest1)
out2 = read(chest2)

write(chest1, in2 - out2)
write(chest2, in1 - out1)
That means you read the state of a network and substract what's being faked by you to get the real value.
Doing all measurements before all writes ensures that it can all happen in one tick (if factorio has anything like those)
and without wait times for the CCnet to stabilise after a write (if factorio does anything like that)

EDIT2: Any approach will probably be given hard time dealing with CCnet loops.
Both situations where both cables lead to one physical network: <--net1--(repeater)--net1-->
and a situation with more repeaters forming a loop: <--net1--(repeater)--net2--(repeater)--net3--(repeater)--net1-->.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by ssilk »

MF- wrote:Can mods create and remove ccnet/power wiring already?
If so, then creation of multi-cable trunks might be possible...
Just create ghost poles behind the real poles and wire them along the real poles.
That gives extra connections for bypassing the 2-CCnets-per-pole limit.
I don't know why you need more than two? One should also be enough, if I have such router/patch bay...
:)
EDIT: Oh, I see what you're talking about.. it's "relaying signals from one cable to another"
For reading a cable.. using smart inserters might work... but would't there be too many / require more ticks for a full readout?
For writing a fake smart chest might do.
Not sure on which post you answer. :)
Would be possible to establish a stable bi-directional connection at all?
Without causing oscillations on the network / desyncs?
Even when there are more of such "connections" on one supernetwork?
Hm. Perhaps I explain how that currently works internally? A cable/network is nothing else than a list in memory where you have key-value tuples. Some say also it's a hash-table, and there are some more names. I draw a picture of that at the top of this thread, you remember? If you add a chest to that network it adds it's items into this list.

So, if you add a wire to this network, nothing special will change. There is also no oscillation in this network possible, cause it doesn't have a feedback or it don't needs some time for the network to transfer the information.

Btw. The electric network works nearly exactly the same. And even the production info has some similarities!

Maybe we speak from completely different things?
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by Blackence »

So I took a look at the lua API and lua itself and hacked something together using only chests and poles.

There's only 1 "input" / "sensor" right now:
- Chest contents (vector of item names with item counts)

There are 3 "modules":
- Filter module: It's a chest with one input pole and one output pole. it takes an input vector of items with item counts and creates an output vector by removing any items from the input vector which are not contained in the filter module chest.
- Count module: Also a chest with one input pole and one output pole. Takes the input vector, sums up the counts for all the items in the vector, and outputs a scalar number (sum of all counts).
- Condition module: Since I didn't feel like introducing true/false boolean values explicitly, I used 1=true/0=false. Module must be configured to have a comparison operation (< or >) and a number to compare against. Input is a scalar number, output is a scalar "fake-boolean" number (1/0, depending on the comparison result). For any real usage scenario, this simple way of setting up the condition is probably not enough. :-)

There are 2 "outputs" / "actors":
- Smart power switch (not sure why I called it "smart", anyway): One "input value pole" and two normal power poles. If the input value scalar number is 1, then both power poles are connected using a cable. If the scalar input number is not 1, then the power poles are not connected. So by connecting a condition module output to the smart power switch input, the condition module controls wheter or not the smart power switch will send power from the left power pole to the right one (or vice versa).
- Smart LED (yeah, very smart): This looks insanely stupid and ugly because I created the sprite in the GIMP. It's not in the video below because I don't want to make you laugh. Anyway, depending on the scalar input value (1/2/3/default) it turns (red/green/blue/off).


The semantics when connecting multiple outputs together are also important: All the values are added up. So "10 iron plate" connected to "5 copper plate and 10 iron plate" results in "20 iron plate and 5 copper plate" when connecting that wire to some input. When adding a third output that emits a scalar value of 3, this results in "20 iron plates, 5 copper plates, and a scalar value of 3". Adding a condition module that currently has its condition fulfilled (=true = scalar 1), the result is "20 iron plates, 5 copper plates, and a scalar value of 4".

So there's no need for a "group module" (DerivePi), because that happens implicitly by connecting multiple outputs to one input. The "summation module" can be simulated using a filter module and a count module.


What I think might be possible to do for inputs:
- light detector (either true/false or even some number indicating how dark it is)
- inventory of a train that is currently on a "smart" piece of rail
- smart radar (assuming this is supposed to count the number of remaining ressources in a ressource field?)
- I guess a few more of the things DerivePi listed, not sure about the API details

Outputs:
- train station that delays train departure based on input value
- enabling/disabling of devices like inserters
- set the smart inserter filter (?? maybe..)

Modules: As long as it is possible to build a working GUI for module configuration, any desired input->output transformation should be possible.

The main issue is that the input/output poles feel strange because it's confusing to have 3 different buildings instead of only 1 when placing a module or sensor/actor. I couldn't figure out how to add 2 "wire connection spots" to a single entity.

Obviously, the code is quite ugly right now. Since I've reused the smart chest and power pole sprite for everything, it is also difficult to work with these things. And there's a scripting error when trying to remove modules/sensors/actors from the map (and probably a lot of other cases) because the code can't handle that. Some of the chests should not be chests, but I just copied that part over because I was too lazy to figure out something that works better. And collision / selection boxes are not quite right either. And a lot of other details are not quite right. You see, I just wanted this to show some reaction when I change something in the smart chest, which it does.

So it's just meant as a proof of concept. If this is supposed to become useful, it needs a lot of work that I can't do because not only do I lack lua and mod API knowledge, I also suck at designing sprites. Though I'm afraid that the wiring part will be quite troublesome, because poles tend to auto-connect to nearby poles. I prevent this by spawning poles at x=10000 y=10000 and then teleporting them to the correct position, but when the user places a pole, things start to be annoying.

Anyway, this is my vid demonstration. Unfortunately my mouse pointer was not captured. You can watch me place down the smart chest, filter module, counter module, condition module with "> 5" condition, and smart power switch. Then I connect the poles and put stuff into the smart chest. I also change the filter chest contents. In case it's not clear, you should watch the smart power switch as it connects and disconnects the left and right power pole when I put stuff into the chest or change the filter config. Yeah, it's probably very confusing. :-)
https://www.youtube.com/watch?v=FjME43PCB0w

Code:
advanced-circuit-network_0.0.1.zip
(13.11 KiB) Downloaded 210 times
This does not state a license. If someone wants to look into improving this or just wants make sure the files are available freely, I'd be happy to use some free license, but I'm just too lazy to decide on a license now. :-) Though I won't sue you if you just build upon it without asking, because I'd love to have a mod that is nice to use and does something like this in a sane way. :-)
User avatar
DerivePi
Filter Inserter
Filter Inserter
Posts: 505
Joined: Thu May 29, 2014 4:51 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by DerivePi »

Fantastic to you Blackence!

Maybe we can get someone to put a graphic together for the "switch"
Attachments
switch.gif
switch.gif (69.47 KiB) Viewed 8773 times
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by ssilk »

Fantastic work. :)

This is about how I think it should work in the end. ;)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by Blackence »

Even with a nice sprite for the switch, it would still need to be constructed out of at least 3 "separate" power-pole-like buildings (entities), as far as I can tell. Sure, they don't have to look like power poles, the sprite can be changed and I think the cable connection position can be changed as well. However, one building to connect the input, and 2 separate buildings to connect two different parts of the power network, are absolutely required unless I'm overlooking something. So that definitely hinders usability and causes weirdness. :(

Oh, and AFAICT, there's no API to disconnect power poles in a sane way. As I believe I mentioned, the mod just destroys the left power pole of the smart power switch, recreates it at x=10000,y=10000, then teleports it to the old position to get rid of all cables. Then the old list of connected power poles is used to re-connect any previously connected copper-cable neighbour, but not the "right power pole" part of the power switch. I now realized that this will of course remove any green/red wires, but there's no way to fix this using the current lua API as far as I can tell.

So.. Yeah, advanced circuit networks should work similar to my hacky mod IMO, but I hope it would do so in a sane way without the restrictions imposed by the lua API and me sucking at solving the "user facing parts" in a nice way. :D Like… Just one entity for each module/sensor/actor, nice config GUI, etc. (Oh, and the way it is calculated should probably be a little more efficient than recalculating everything every 60 ticks.)


I'd also love "smart trains". Something like a train that just idles in the main base until an outpost is low on repair packs. A "smart station" is not enough for that, because the train needs to skip any outposts which are not low on supplies, so there should be a separate condition attached to every train station in the train schedule, and those where the condition evaluates to false should be skipped. This may or may not be possible to implement already using the current Train API "schedule" property, however I can't fathom any acceptable way for the user to configure something like this. Well… there might be a way that is not absolutely impossible to use and doesn't involve LUA scripting on the user's part, but it would be a lot of work (if it works at all) for something that is just another dirty hack no-one in his right mind would use. It involves adding stationary RF transmitters to outposts, a new GUI to set a transmitter name, adding RF receiver rail cars to trains, and a new rail car GUI to configure conditions for stations (and having to type the corresponding station name and transmitter name manually in that GUI).
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

ssilk wrote: Maybe we speak from completely different things?
Well...
It seems that you failed to notice I'm talking about a possiblity to make a mod that would do the requeted "cable trunking" right now.
Please re-read the post.
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

@Blackence
Oh wow, I like that too :)

Regarding multi-cable connection..
Smart inserters can connect to two networks... but I guess that's what you're talking about that you didn't figure out.

What do you think about bridging (differently-coloured) Blackence-CCnet networks?
EDIT: Oh, right, you're using "power" wires since CCnet's cannot be manipulated.
That's a pity
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

@Blackence:
I wrote an API request just to find out that wiring CCnet wires is also possible starting from 0.10.0
https://forums.factorio.com/forum/vie ... 065#p44055

I'll ask about disconnecting wires too.

EDIT:
PS: Since evalutation cycles are forbidden...
Do you think it would be better for the filter module to act the way filter inserters work (empty filter = all)
OR
a button to explicitely set whitelist/blacklist
OR
a separate "signal relay" machine

Given that I might try to adjust the filtered item types using inserters,
perhaps the most consistent first option might not be that desirable? What do you think?
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

I peeked in your code,
it seems all nice, clean and thought-through.

Only one thing baffles me..
You create the power switch with "context.enabled = true", while there is no "connectneighbours" to actually do that.

PS: "controlSmartPowerSwitch" duplicated the code of "createPole" instead of calling it
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

Yay, it's now possible to un-wire in 0.11.x :)
Added disconnectneighbour: used with electric poles; takes the circuit connector to disconnect - none to disconnect standard copper wire.
Not sure about probing such connections.
I remember you could enumerate power-wiring neighbours, but not CCnet neighbours?
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by Blackence »

MF- wrote:Regarding multi-cable connection..
Smart inserters can connect to two networks... but I guess that's what you're talking about that you didn't figure out.
I'm still not sure about the circuit network lua API and what it can do. Using green wire for input and red wire for output, and just one "power pole"-like building for the module might be possible, but then connecting one output (red) to the input (that needs to be green) of another module is rather difficult when using the modules. I actually prefer the way I did it in the current version 0.0.1 of the mod, where all the cables are just normal power cables. :D I find it less confusing. Maybe I'll try to switch to using only red/green cable instead of power cables so there are no issues with new power poles auto-connecting to the "advanced circuit network" when building them.
What do you think about bridging (differently-coloured) Blackence-CCnet networks?
EDIT: Oh, right, you're using "power" wires since CCnet's cannot be manipulated.
That's a pity
I think that "bridging" them is not really useful, because you can already connect different networks (i.e. networks that are not connected), which results in summation.
MF- wrote:PS: Since evalutation cycles are forbidden...
Do you think it would be better for the filter module to act the way filter inserters work (empty filter = all)
OR
a button to explicitely set whitelist/blacklist
OR
a separate "signal relay" machine
I'm not sure what the third option would do. :-) For the first one, I'm open to change it to "emtpy filter = don't filter at all" if you think that would help with your use case. I'm not sure how to do the GUI stuff, so adding a white/blacklist button is difficult. :D Since I haven't thought a lot about possible use cases for this mod, I don't really know what to say.
MF- wrote:You create the power switch with "context.enabled = true", while there is no "connectneighbours" to actually do that.
This seems like a bug. I probably haven't noticed it earlier because when placing the smart power switch, nothing is connected to its input. So the next time the network is updated (max. 1sec), the smart power switch gets disabled and it's consistent again.
MF- wrote:PS: "controlSmartPowerSwitch" duplicated the code of "createPole" instead of calling it
Right, I think there was a reason for that, but I seem to remember that I changed the way createPole() works, so that reason is probably no longer valid.
MF- wrote:I remember you could enumerate power-wiring neighbours, but not CCnet neighbours?
Not sure about the current status. The docs say "can be used only for electric pole or entity with pipe connection. Contains table of connected electric poles [..]". Maybe that includes connected circuit network poles?
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

Sorry my reply took so damn long.
Blackence wrote:
MF- wrote:Regarding multi-cable connection..
Smart inserters can connect to two networks... but I guess that's what you're talking about that you didn't figure out.
I'm still not sure about the circuit network lua API and what it can do. Using green wire for input and red wire for output, and just one "power pole"-like building for the module might be possible, but then connecting one output (red) to the input (that needs to be green) of another module is rather difficult when using the modules.
That was actually the purpose of the "bridging" device. To patch a red cable into a green one.
Ultimately that should allow you to create "cable trunks" by placing several lines of CC-net-connected poles over each other
That will provide 2*N signals in one cable trunk.
With the bridging device, such signals can be input/output to any desired cable color at a breakout hub.
Blackence wrote: I actually prefer the way I did it in the current version 0.0.1 of the mod, where all the cables are just normal power cables. :D I find it less confusing. Maybe I'll try to switch to using only red/green cable instead of power cables so there are no issues with new power poles auto-connecting to the "advanced circuit network" when building them.
Sounds good (if possible)
Or just allow both CCnet colors and ignore which one the player used :)
(That will allow the player to connect "red" and "green" networks just by hooking them to a common pole. Note the quotation marks)
Blackence wrote:
MF- wrote:What do you think about bridging (differently-coloured) Blackence-CCnet networks?
I think that "bridging" them is not really useful, because you can already connect different networks (i.e. networks that are not connected), which results in summation.
You're right.
This question was meant to be about in-game CCnet networks and whether those could be bridged.
But that seems rather off-topic -> my question is void.
Blackence wrote:
MF- wrote:PS: Since evalutation cycles are forbidden...
Do you think it would be better for the filter module to act the way filter inserters work (empty filter = all)
OR
a button to explicitely set whitelist/blacklist
OR
a separate "signal relay" machine
I'm not sure what the third option would do. :-) For the first one, I'm open to change it to "emtpy filter = don't filter at all" if you think that would help with your use case. I'm not sure how to do the GUI stuff, so adding a white/blacklist button is difficult. :D Since I haven't thought a lot about possible use cases for this mod, I don't really know what to say.
This was all about using an empty filter as a "diode" to allow signals from one network to pass into the other, but not the other way around.
The third option would make the "diode" into a separate device. It's an odd option if an empty filter could do it.
Blackence wrote:
MF- wrote:I remember you could enumerate power-wiring neighbours, but not CCnet neighbours?
Not sure about the current status. The docs say "can be used only for electric pole or entity with pipe connection. Contains table of connected electric poles [..]". Maybe that includes connected circuit network poles?
I guess that's try and see.


PS: Witht the added "sanity checks on coordinates",
the currently used "teleport pole from far lands" approach might not be possible anymore.
Since we were given "disconnectneighbour" some releases back, I don't see it as a problem.
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by Blackence »

Oh, I don't mind late responses since it often takes me quite a while to get around to posting as well. ;)

Now I think I understand the red/green wires + bridging ideas. I still haven't looked at the API (haven't even played 0.11 yet… :( ), so I don't know if it's possible to do that. It sounds like a nice idea so we can have 2 signals (1 red + 1 green) per pole-line.

The diode sounds pretty interesting. I just now realized that "filter that doesn't filter anything" works like a diode. I guess it'd be more intuitive to have a separate device for that?
MF- wrote:I guess that's try and see.
Yes, unless someone updated the wiki.
MF- wrote:Since we were given "disconnectneighbour" some releases back, I don't see it as a problem.
I agree. Maybe I can look into it soon-ish. We recently moved places and still not 100% done yet, and in my free time I'm currently occupied with other pet projects, so let's see. :) Again, of course, anyone is free to work on the "mod" / distribute it with or without modification / whatever, even though I haven't put explicit licensing info in there because I was too lazy.
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Thoughts about circuit network (while I'm just on it)

Post by MF- »

Blackence wrote:Now I think I understand the red/green wires + bridging ideas. I still haven't looked at the API (haven't even played 0.11 yet… :( ), so I don't know if it's possible to do that. It sounds like a nice idea so we can have 2 signals (1 red + 1 green) per pole-line.
And then (if bridging would be available), if a mod creates a "multipole"-line by placing several poles over each other,
such mod would be able to pretend there is a "cable trunk" which has many "cores/connectors/threads/pins/slots",
to which any cable color can be successfully connected. (Probably using some kind of a "patchboard/extractor" device)

Example:
A mod presents to the user a "cable trunk stand" pole.
Upon creation, such pole would then create 5 invisible/shrunk regular poles "behind" itself,
-- storing their references in an array like so: self.internal_poles[1], self.internal_poles[2], ..., self.internal_poles[5]
If it detects another "cable trunk stand" pole near itself (or perhaps an user wires them up manually using a "trunk cable"),
-- it would wire up all it's internal poles to the respective other trunk's internal poles (using both red and green wiring).
That would give the trunk cable 10 connection "slots/cores/whatever".
|
5 red of those connections would be internally red, 5 would be green.
To make it practical, such detail would have to be hidden from the user,
allowing her to connect any wire color to any "slot/core/whatever" (even if the internal wire color would differ)
That's where a "bridging" device would be needed.
For the connection, another device "trunk branch/extractor / patchboard" would be used.
Blackence wrote:The diode sounds pretty interesting. I just now realized that "filter that doesn't filter anything" works like a diode. I guess it'd be more intuitive to have a separate device for that?
I'm not sure.
I would say in factorio having fewer types of machines is preferred.
Also smart inserters without a filter move everything AFAIK.

On the other hand (especially if bridging turns out to be possible), why should the filter be a one-way device?
Then it would either have some button/knob to configure it's (bi)direction and thus be obvious about its diode functionality,
or a separate device would be indeed necessary.
Post Reply

Return to “Ideas and Suggestions”