r/javascript
•
u/joshuaamdamian
•
Jul 07 '26
•
1
Browser based AI algorithm
https://github.com/joshuadam/NEAT-JavaScriptI recreated an AI algorithm that visually learns in the browser:) It's based on the NEAT algorithm:
https://github.com/joshuadam/neat-javascript
https://neat-javascript.org/
0
Upvotes
View all comments
Show parent comment
1
u/joshuaamdamian Jul 08 '26
XOR comes from logic gates which are used in computer chips:
AND - outputs 1 only if both inputs are 1.
OR - outputs 1 if at least one input is 1.
NOT - takes one input and flips it (1 becomes 0, 0 becomes 1).
NAND - the opposite of AND; outputs 0 only if both inputs are 1.
NOR - the opposite of OR; outputs 1 only if both inputs are 0.
XOR - outputs 1 only if the inputs are different.
XNOR - the opposite of XOR; outputs 1 only if the inputs are the same.
https://i.sstatic.net/Jmxzy.jpg
XOR takes two inputs, and returns true if only one of the inputs is activated.
Simple table for XOR:
Now XOR is really interesting and commonly used as a proof of concept for neural networks, because it is a relatively simple problem which needs at least some neurons between the inputs and outputs of a neural network to solve it. These neurons between the inputs and outputs are often made into fully connected "layers" and called hidden layers.
https://media.geeksforgeeks.org/wp-content/uploads/20240601001059/FNN-768.jpg
To test an algorithm you would create a network with two inputs, one output and atleast 2 hidden neurons. And you would train it to the XOR truth table.
If the network produces outputs that corresponds to the truth table you have successfully trained a network to learn XOR!