Lights Out...with project red

steve g

New Member
Jul 29, 2019
445
0
0
I took a break from my cpu build and was toying around my redstone map, and wondered hmmm...lights out with project red...challenge accepted ;)




this is based on bennycube's design (which you see here in the purple wool version)

the logic is exactly the same...the pressure plate sends a signal to its neighbors and to its own cell's t flip flop (a toggle latch). the blue line is the board reset signal. whats not visible in the shots is there's also an AND gate on the other side of the block holding the toggle latch...the output goes into the red wire going back to the toggle, that's the reset logic. im thinking *maybe* it can be shrunk down a bit more...but for now, it works.
 
Last edited:

steve g

New Member
Jul 29, 2019
445
0
0
heh so i had to come back to this. I figured out a way to make the circuit *much* smaller

the 2 boards are identical...the one on top is the one i did in the last post. left is bennycubes version..right is mine


and look at the difference! mine is only 3 blocks high, including the light board. I managed to pull this off with some IC trickery.
the circuit itself is very simple. white lines are inputs from surrounding cells, orange is output to neighbors. green is the signal from the pressure plate. pink is the toggle output which goes to the lights and blue is the reset signal. now you might be thinking...the input/output channels cant reverse roles between neighbors, seeing how they are linked via bus wires. the way the schematic is shown you are correct. so make *2* versions of this same chip, and flip the channel colors for input/output. use both chips, in a checkerboard pattern, and it works perfectly. and it works fast too. the toggling of the neighbors is instant now, making this probably the fastest, and (hopefully) most compact, version of lights out for MC ;)
 

steve g

New Member
Jul 29, 2019
445
0
0
i bet you guys are getting tired of me and all this project red nonsense...but never the less...i actually managed to make it even smaller ;)


2x2 wide/high, and 5 deep (for the reset signal grid you see on the back). this runs exactly the same as the 2nd version, using the same ic chips in a checkerboard pattern. only difference is I did a wall instead of the disco floor, and had to get really creative with cover strips and covers to block the bus wires from connecting to the wrong sides and somehow managing to get both input from and output to the same lamp.
 

steve g

New Member
Jul 29, 2019
445
0
0
all these lights out builds I've seen were always missing something: a way to initialize the board with a random pattern to solve. I might be wrong tho, i've seen some pretty crazy builds on redstone servers before, but here's my take on it



Whats going on here is there's a group of dec randomizers sending signals to the bus above it. The randomizer on the left controls which of the 3 groups gets to go through to the bus above. This was done so only one of the 9 lines will go active at any time. on top are 2 groups of outputs with latches that control which wires on the back of the board go active. the left side controls the wires going across, the right bus controls the vertical wires. the difference is the right bus has pulse formers, the left does not. this basically 'clocks' a cell when the right bus sends a pulse. the bottom right is the clock circuit that controls the latches on both sides.

I tried doing this first with an IC gate...but that was an epic fail because with IC gates, the pulse to a latch is too long (even a single tick!), and allows more than one line to go active. I tried repeaters, but that did nothing to stop the latches from getting multiple values clocked in. the dec randomizers are designed to have only 1 output enabled, but in an ic, they run VERY fast. Fast enough to get a couple values in while the pulse to the latches does its thing. IC's are great for combinatorial logic, but not sequential or clocked circuits. So I had to do it in the open. It works great like this, and the puzzles generated are solvable too. You just need to let it run for a minute or 2 to set up the board.
 

steve g

New Member
Jul 29, 2019
445
0
0
i couldnt leave it alone..i dont like having big circuits like that flying about when it could be done in an ic...and so I have a new IC that does the random board setup i had going in previous post

so i changed up the random generation so it generates a 4 bit number. feed that 4 bit number into a 4-16 decoder (all those buffer/inverter cells). the outputs work the same as the last circuit..left side holds a horizontal line active while the right output sends a pulse over the selected vertical line, 'clocking' a cell to toggle its state.

now the clever bit is that timing circuit. here goes:
the blue line on the left is the input telling the chip to start the process. this goes into an and gate, which goes into a toggle latch. the white wire connecting the 2 makes sure that once the circuit is active and running...no further input will cause any changes on that toggle. Anti spam control.

after the toggle, the blue wire goes active, sending a pulse to start up the timing circuit on the top right. the and gate just left of the first state cell is there to allow the signal to keep looping as long as that blue line is still active. from there its a sequence of state cells:
1) send a pulse to the random number generator
2) send a pulse to the left output latches
3) send another pulse to the random number generator
4) send a pulse to the right output latches and go back to start of timing loop.

on every iteration, a counter gets incremented (follow the blue wire down, youll see the counter with the +/- symbols on it). the counter is set to min 0/max 50. this is also hooked up to an rs latch. When the counter hits its max value, the plus side goes active and does 2 things: toggle the input toggle latch, and toggle the rs latch. when that rs latch gets a signal from the cyan wire, the magenta line goes low, activating that timer on the left...this is used to decrement the counter back down to 0. once it hits 0, the counter's minus side goes active, toggling the rs latch and disabling the timer doing the countdown. all this is a reset circuit to get the chip ready for the next run.

having hooked it up...all works well now, and still fairly compact given how much its doing
 
  • Like
Reactions: Kel_Co

steve g

New Member
Jul 29, 2019
445
0
0
This is honestly really impressive. How did you learn to do all this?
years of redstone and trying to understand basic logic, timing, digital logic circuits..i've been playing this mod, and its predecessors all the way back to FTB ultimate, with the original RedPower mod that started it all (Eloraam...we really need you back :( ). Also helps to know how to throw around a few hundred lines of code in your programming language of choice ;)

and about that code...i came up with something...evil. And smaller.


This is as good as it gets, without getting into command blocks or creating a custom mod (i almost did that, woulda been kinda cool, but a hack). Computercraft mining turtles are running this board.
I was inspired by the command block version you see on youtube...i dont have the link on me..but it uses command blocks to swap out the wool blocks you toggle. And this one is very evil indeed...because now there are *4* states for each light...black, orange, magenta, lime. in that order. I can only find one reference to this calling the game Colors Out...and it is annoyingly hard to solve the board ;)

the code running the turtles is pretty simple (all the turtles are labeled 'lights out')
Code:
turtle.select(1)
local state = 1
local myTimer = 0

local function toggle()
    state = state + 1
    if state > 4 then state = 1 end
    turtle.dig()
    turtle.select(state)
    turtle.place()
end

local function setNeighbors(v)
    rs.setOutput("top", v)
    rs.setOutput("bottom", v)
    rs.setOutput("left", v)
    rs.setOutput("right", v)
end

while true do
    local event, id = os.pullEvent()
    if event == "redstone" then
        if rs.getInput("front") then
            setNeighbors(true)
            myTimer = os.startTimer(0.2)
        end

        if rs.getInput("top") then
            toggle()
        end

        if rs.getInput("bottom") then
            toggle()
        end

        if rs.getInput("top") then
            toggle()
        end

        if rs.getInput("left") then
            toggle()
        end

        if rs.getInput("right") then
            toggle()
        end
    end

    if event == "timer" and id == myTimer then
        setNeighbors(false)
        toggle()
    end
end
i'm using os events to poll for redstone signals. a front signal means that block was toggled by user, so it will send a rs signal to its neighbors and starts that timer. you need that to let the game process the redstone update. the timer event hits, trigger the blocks own toggle function and disabling rs signals to neighbors. the cool bit is the toggle function itself..all it does is increment state (or resets to 1 if overflowed), digs the current block in front of the turtle, selects a slot in inventory, and places that block in front of turtle.

assuming you start with a black board, all the turtles start with an empty slot 1 (and all selected to slot 1), orange wool in slot 2, magenta wool in slot 3, lime wool in slot 4. now you see how the toggles work...dig block (and retrieve it to previous state), set inventory slot to current state, place block.

its a slow update doing it this way tho. for a moment you can see the turtles before the new blocks get placed...cc must have some steep timing penalties for digging/placing blocks.

the trick now is the input..use a wood button, place it where you want to toggle and press it. the turtles handle the rest. the button will pop off, so it can be reused.

as evil as this is, you can see there's room for more. I'm only using 4 slots on the turtles. hmm.. 16 colors, shall we? not hard to do, just change one line of code, and set up the turtles accordingly, reload the map (you dont want to go rebooting all those turtles by hand...trust me on this ;)

file to play with the turtle version: https://drive.google.com/open?id=0B2ucBrdZgWgnbVRuenVuLU82c1E
make sure your running a pack for 1.7.10 with computercraft to load that map.
 
Last edited:

lenscas

Over-Achiever
Jul 31, 2013
2,023
1,799
248
question, wouldn't it be easier to replace
Code:
if event == "redstone" then
     if rs.getInput("front") then
         setNeighbors(true)
         myTimer = os.startTimer(0.2)
     end

     if rs.getInput("top") then
         toggle()
     end

    if rs.getInput("bottom") then
        toggle()
    end

    if rs.getInput("top") then
        toggle()
    end

    if rs.getInput("left") then
        toggle()
    end

    if rs.getInput("right") then
        toggle()
    end
end
with
Code:
if event == "redstone" then
     if rs.getInput("front") then
         setNeighbors(true)
         myTimer = os.startTimer(0.2)
     else
         toggle()
     end
end
Also, you have top listed twice, not sure if that is intentional...
Nice work anyway :)
 

steve g

New Member
Jul 29, 2019
445
0
0
yep my bad, goofy typos.

you have to realize the redstone event happens 2x on every incoming rs change...once when signal goes up, then when it goes low. the redstone event doesnt distinguish which side or state. just that it happened. and luckily it doesnt trigger on the rs.setOutput calls..that would've sucked bad. would have been nice if the event did include side/state...

without those rs.getInput calls..your code would be toggling the cell twice on every incoming neighbors events.

actually this is a bit less verbose:
Code:
turtle.select(1)
local state = 1
local myTimer = 0

local function toggle()
    state = state + 1
    if state > 4 then state = 1 end
    turtle.dig()
    turtle.select(state)
    turtle.place()
end

local function reset()
    turtle.dig()
    state = 1
    turtle.select(state)
    turtle.place()
end

local function setNeighbors(v)
    rs.setOutput("top", v)
    rs.setOutput("bottom", v)
    rs.setOutput("left", v)
    rs.setOutput("right", v)
end

local function toggleNeighbors()
    setNeighbors(true)
    myTimer = os.startTimer(0.2)
end

local signals = {
    ["top"] = toggle,
    ["bottom"] = toggle,
    ["left"] = toggle,
    ["right"] = toggle,
    ["back"] = reset,
    ["front"] = toggleNeighbors
}

while true do
    local side, action
    local event, id = os.pullEvent()
    if event == "redstone" then
        for side,action in pairs(signals) do
            if rs.getInput(side) then action() end
        end
    end

    if event == "timer" and id == myTimer then
        setNeighbors(false)
        toggle()
    end
end
i added a reset function...run a framed red alloy line (or something that links all the back sides of those turtles) and put a button on it
 
Last edited: