Format code

This commit is contained in:
Joop Schilder 2020-11-14 11:17:31 +01:00
parent cde99a0d0a
commit 18d7cce366

View File

@ -8,9 +8,7 @@
Not that it matters, as it's randomly chosen, but done anyway for the sake of repeatability. Not that it matters, as it's randomly chosen, but done anyway for the sake of repeatability.
Joop Schilder Joop Schilder
Sat 14 Nov 01:30 Fri 13 Nov
One of the nights that I shall remember as if it were me who was in control of my brain.
*/ */
const NUM_NODES = 20; const NUM_NODES = 20;
@ -25,7 +23,7 @@ const TRUTH_TABLE_SIZE = (1 << NUM_CONNECTIONS);
$truth_table = []; $truth_table = [];
for ($i = 0; $i < TRUTH_TABLE_SIZE; $i++) { for ($i = 0; $i < TRUTH_TABLE_SIZE; $i++) {
$truth_table[$i] = random_int(0, 100) % 2; $truth_table[$i] = random_int(0, 100) % 2;
} }
$nodes = []; $nodes = [];
@ -72,7 +70,7 @@ function propagate(array $nodes, array &$connections, array &$truth_table): arra
for ($i = 0; $i < NUM_NODES; $i++) { for ($i = 0; $i < NUM_NODES; $i++) {
$tt_index = 0; $tt_index = 0;
for ($j = 0; $j < NUM_CONNECTIONS; $j++) { for ($j = 0; $j < NUM_CONNECTIONS; $j++) {
$tt_index += $nodes[$connections[$i][$j]] << (NUM_CONNECTIONS - 1 - $j); $tt_index += $nodes[$connections[$i][$j]] << (NUM_CONNECTIONS - 1 - $j);
} }
$next_nodes[$i] = $truth_table[$tt_index]; $next_nodes[$i] = $truth_table[$tt_index];
} }