NandGame – Build a Computer from Scratch - https://news.ycombinator.com/item?id=36862274 - July 2023 (3 comments)
NandGame – Build a Computer from Scratch - https://news.ycombinator.com/item?id=31055307 - April 2022 (14 comments)
NandGame – Build a Computer from Scratch - https://news.ycombinator.com/item?id=25282507 - Dec 2020 (136 comments)
Show HN: Online challenge: Build a CPU from scratch - https://news.ycombinator.com/item?id=17508151 - July 2018 (60 comments)
It’s a bit like saying “darn I can never remember which Prime Minster passed the corn laws or the name of the guy who started refrigerated shipping in the USA.
The point is if we have a grasp of the essential narrative (something like “wars require engineering, agricultural revolution, Industrial Revolution, history is class warfare” that background acts like a magnetic field for all the new pieces of information, aligning them correctly.
Anyway, relax, be kinder to yourself.
I have done this before in another version of this game but for the life of me cannot see how to get to a single output from all of the components I have placed on the screen.
It does look cool but without more directions or hints I am done for.
I found this[0], which is nice in that it's interactive (you can click the inputs to change their values and see how the current flows), though I think the visuals are a little harder to understand. Would be nicer if it had clearer delineation of the relays, and their inputs and outputs labeled with more than just their voltages.
[0] https://everycircuit.com/circuit/4954026060021760/relay-base...
One of the relays gives you "A and B". The other gives you "A and not B". "A and not B" with A = 1 is just "not B".
That should be a clue that you're up the wrong alley. A single output means a single output...
(or a 3-state buffer, but I don't think that'll appear in the game)
My advice is to treat it like a puzzle: "how do you implement NAND in relays _if_ you can not do any parallel connections". When formulated this way, it is pretty easy to solve.
(The relays disappear in level 2 and we switch to digital logic, so "cannot parallel outputs" limitation makes much more sense there. I am guessing they didn't want to make up a new mechanic just for a single level, but I wished they'd explain it better)
May I ask how you would have preferred to solve the first level if the game didn't have limitations?
(In real life, I might put a diode OR + single relay-based inverter, but that's too far into analog logic for the essentially digital game)
Once you complete this (ignoring the first level where you actually build a NAND gate) you essentially get very much what looks like a Neural Network (since it takes 2 neurons to represent a NAND gate), n layers deep, with a lot of zeros in the weight matrices, and some storage.
Here is my question: given the input/output semantics at the assembly level, is it possible to train a blank neural network to look like this? Backprop obviously wouldn't work, but perhaps there is some form of directed search one could use?
Of course, occasionally there would be a system where this didn't fully happen, and you'd get some node/s doing some funky stuff with the linear parts of the activation function, but that doesn't negate the fact that such networks can and often do find the slice/AND/OR solutions.
Really intrigued by the "similarity" of logical gates - nn - batteries/ transistors
Does anyone have a decent method to train neural networks without backprop? I think the information bottleneck sort-of works, but it's hard to evaluate the mutual information without a neural network.
I found them both fun and educational, but I thought the NandGame was more fun. But it's good to know about the connections, for example because there are more follow-on exercises that you can do from Nand2Tetris (working with higher layers of computer software) after you complete the NandGame. Or you can just be aware that you can talk about the experience and the substance with people who have done the other version!
It's very similar to the Nand2Tetris book.
Fantastic game even in early release!
Also, it's on GOG (https://www.gog.com/game/turing_complete) which is always nice.
I got an iCE40 board[1] as the open-source story was decent and price was low. There might be better options now.
[1]: https://www.digikey.com/en/products/detail/lattice-semicondu...
Some people might have wimped out and just cobbled up a USB translator, but Wirth knew how to take care of things properly: he got an FPGA board, made a soft CPU, and then put all the stuff on top (his OS, his windowing system, his language toolchain, etc.) that would enable him to run his h/w design app and text editor, thereby allowing him to play with more soft CPU-designs ... but this time while using his favourite mouse.
A relay is a mechanical switch controlled by an electromagnet composed of a coil of wire wrapped around an iron core, as depicted on the icon. When current flows through the coil, it pulls the metal spring towards it, which can either allow current to flow from "in" to the output or disconnect the current flow from "in" to the output. Those are the two types of relay components on offer.
c = coil, if it is powered it will toggle the switch.
in = the value (1 or 0 here) that will pass through if the switch is closed.
In code:
def default_on(c, in):
if c == 1: return 0
if c == 0: return in
def default_off(c, in):
if c == 1: return in
if c == 0: return 0
The separate power source allows you to obtain a 1 value (since this is around digital logic I'm not going to break it down further) regardless of what the two input values are.Consider a situation like this: How would you output 1 every time both inputs are 0? You need some high value to draw from, that's what the power source is for. So the input signals themselves may not be enough.
https://codehiddenlanguage.com
https://codehiddenlanguage.com/Chapter08/ - illustrates logic with relays.
It's a brilliant book.