function process(){
function populate(){
function score(){
var total = "";
for (var v = 0; v < g.nn.data.length;v++) {
total += activateNetwork(network,v);
}
return total;
}
function updateCyle(){
s = score();
g.temp = network;
network = mutateNetwork(network);
S = score();
if (s < S) network = g.temp;
else if (g.bestScore > S) {
g.bestScore = S;
g.nnBest = network;
}
g.nn.index++;
if (g.nn.index%10==0) {
document.getElementById("neuralNetworksDisplay").innerHTML = g.bestScore;
updateCyle();
}
else if (100 > g.nn.index) updateCyle()
}
var network = initNetwork(g.nn.Z);
updateCyle();
}
g.nn = {
population : [],
index : 0,
total : 0,
Z : 2,
threshold : 0.01,
epochLimit : 20,
epochIndex : 0,
forex : false,
};
g.nn.data = [
[[0,0,0,0],[0]],
[[1,0,0,0],[0]],
[[1,1,0,0],[0]],
[[1,1,1,0],[0]],
[[0,1,0,0],[1]],
[[0,0,1,0],[1]],
[[0,1,1,0],[1]],
[[0,1,1,1],[0]],
[[0,0,1,1],[0]],
[[0,0,0,1],[0]],
[[1,0,0,1],[0]],
[[1,1,1,1],[0]],
];
populate();
var t = JSON.stringify(g.nnBest);
navigator.clipboard.writeText(t).then(function (){});
}
g.nnBest = [];
g.bestScore = 100;
process();