Re: Combinator Contraptions
Posted: Thu Jul 23, 2015 7:09 am
I'd really like for lights to be able to change color according to the value of a signal.
This can be done with some smart chests, though its a little bulky. You can measure how many pass through the chests in a certain amount of time.Peter34 wrote:I'd love to see a Sensor to measure Belt throughput, but I don't know that the devs have any such plans.ratchetfreak wrote:or the amount of ore going through a belt.
This is in the roadmap for 0.13 last I heard.Sander Buruma wrote:I'd really like for lights to be able to change color according to the value of a signal.
I've got huge banks of binary ram that I'm putting up in my world for (eventually), a computer. But I am dreading actually making the CPU. I have no idea where to even begin, besides making an ALU...GopherAtl wrote:@lupoviridae: nice! Seems like a rather different approach from mine, particularly in generating the pulses. I've got one that adds addressing somewhere, but haven't gotten it properly tiling yet; I actually needed this one for something in my game, while the addressable memory banks, I have thought of no practical use for, yet. Toying with putting together a basic CPU at some point, though, so will need it for ram at that point.
Honestly I only made the binary RAM because I wanted to learn how real computers work. I self-taught myself everything in the past month or two, starting with how individual logic gates work. I figured since I can't build a computer IRL, building one in factorio would be the best way to test my knowledge. Now that I know I can do it, I'm thinking of just dropping the project, and starting again with a more Factorio-friendly layout.GopherAtl wrote:I couldn't justify dealing with binary ram at this point, having a good, fast, and seemingly reliable 32-bit memory cell to work with instead. As for the rest of the computer, well, other than memory and the ALU, all that's really left is an instruction decoder, and possibly a bank of ROM for entering the program. How complex the instruction decoder is depends entirely on your instruction set. If you're not sure how to approach it, just with a very simple one. Heck, if you use registers that output "all," a single cell of rom could have the operation, source address, and destination addresses, all thrown on a bus together on separate signals, then you wouldn't need much real decoding at all, just a master clock that directs everything.
with the 32 bits you can do just about anything with just a = decider for each instruction type in 1 signal and using a few other signals for the registers (or use divide, multiply, subtract = modulo to extract things)GopherAtl wrote:I couldn't justify dealing with binary ram at this point, having a good, fast, and seemingly reliable 32-bit memory cell to work with instead. As for the rest of the computer, well, other than memory and the ALU, all that's really left is an instruction decoder, and possibly a bank of ROM for entering the program. How complex the instruction decoder is depends entirely on your instruction set. If you're not sure how to approach it, just with a very simple one. Heck, if you use registers that output "all," a single cell of rom could have the operation, source address, and destination addresses, all thrown on a bus together on separate signals, then you wouldn't need much real decoding at all, just a master clock that directs everything.
Lupoviridae wrote:I came up with my own register, capable of storing any value for any given items. For example, it could store 512 iron plates, 210 copper, and 123 coal, all in one register. It essentially takes a snapshot of everything currently on the red circuit.
A couple things to keep in mind:
iE means output Everything (input count)
In implementation, the wires labled red and green would all be connected to a main bus. I ommitted this in the diagram to make it easier to read.
Input for each box is on the left, output is on the right.
Here's the wiring diagram: Combinator 6 in the diagram is what does the heavy lifting, and it works by using "pulsed" (single tick length) signals. For this reason I call it a "Pulsed-Value Register" or "PVR".
In this setup, the green wire carries the read ("0") and write ("1") signals as well as the address ("A"), while the red wire carries data.
The first pulse of a green signal to that combinator causes it to remember all current input values. The next clears the memory. This does mean that before it can be used, the register must fist be initialized with a single green pulse, which can be done by disconnecting one of the combinators labeled 4 and performing a dummy write.
Here's the breakdown of what each component does:
1) If the address signal ("A" == 5) and write ("1" == 1) are both enabled, outputs "Blue" == 2
2) If "Blue" == 2, outputs "Red" == 1. This gets added to the constant combinator for a total signal of "Red" == 0 and "Green" == 1.
3) While "Red" == 0, initiates a counter that counts up until "Red" =/= 0, at which point it resets. This is what allows the pulsed signals in the next step
4) When "green" from the counter hits 1 and 2, pulses green signals into the next cell.
5) Passes the input signal from the red wire to the memory component when the green pulses occur.
6) This is the memory component. First green pulse causes it to store all input values into memory. The next green pulse erases memory. Once initialized, this happens in reverse, so when a write occurs, it first erases the old memory, then writes the new values.
8) When the address ("A" == 5) and read ("0" == 1) are both enabled, passes "Blue" == 2 to combinator 7.
9) Filters out the "Blue" == 2 and "Green" == 1 signals from the read output.
7) When "Blue" == 0 (a read occurs), passes the value of combinator 6 onto the red wire.
PS. I will post an in-game picture later.
I have one: https://forums.factorio.com/forum/vie ... 706#p92314XKnight wrote:This setup is only for storing values, without any address checking (you can add one address check in input and one in output:)).
"0 signal" is increasing while the system has "0 signal = 1" in input, and it also can be removed (but who cares?).
The problem with that is that it involves Inserters, and Inserters will slow the throughput down, relative to if the stuff is just moving along a Belt and getting counted by a Sensor on or next to the Belt. I want something I can put on my Iron Ore/Iron Plate Belts, and those are - I hope this is obvious - high-throughout Belts.Lupoviridae wrote:This can be done with some smart chests, though its a little bulky. You can measure how many pass through the chests in a certain amount of time.Peter34 wrote:I'd love to see a Sensor to measure Belt throughput, but I don't know that the devs have any such plans.ratchetfreak wrote:or the amount of ore going through a belt.
The one possibility is to measure throughput at the spot where stuff comes out of the furnace, which would double as a buffer.Peter34 wrote:The problem with that is that it involves Inserters, and Inserters will slow the throughput down, relative to if the stuff is just moving along a Belt and getting counted by a Sensor on or next to the Belt. I want something I can put on my Iron Ore/Iron Plate Belts, and those are - I hope this is obvious - high-throughout Belts.Lupoviridae wrote:This can be done with some smart chests, though its a little bulky. You can measure how many pass through the chests in a certain amount of time.Peter34 wrote:I'd love to see a Sensor to measure Belt throughput, but I don't know that the devs have any such plans.ratchetfreak wrote:or the amount of ore going through a belt.