preliminary fixes/removed typos, etc.

This commit is contained in:
Tom Zuidberg
2026-06-13 21:38:10 +02:00
parent 4a059b8451
commit 584f44166f
4 changed files with 45 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
from itertools import product
from random import random
funcs = [
lambda x1, x2, x3, x4: not x2,
@@ -14,6 +15,13 @@ sequential_sync_funcs = [
lambda x1, x2, x3, x4: (not x2) ^ x4,
]
probabilistic_funcs = [
(1, funcs[0], None),
(1, funcs[1], None),
(1, funcs[2], None),
(0.5, funcs[3], lambda x1, x2, x3, x4: not x3),
]
nodes = []
@@ -39,6 +47,17 @@ def sequential_update(order):
nodes[i] = funcs[i](*nodes)
def probabilistic_update():
global nodes, probabilistic_funcs
funcs = probabilistic_funcs
temp = nodes.copy()
for i in range(len(funcs)):
probability, *nodeFuncs = funcs[i]
func = nodeFuncs[0] if probability >= random() else nodeFuncs[1]
temp[i] = func(*nodes)
nodes = temp
def state_to_str():
return "".join(str(int(i)) for i in nodes)
@@ -61,14 +80,16 @@ def get_table():
def update():
return synchronous_update()
return sequential_update([0, 1, 2, 3])
# return synchronous_update()
# return sequential_update([0, 1, 2, 3])
return probabilistic_update()
# return block_sequential_update(...)
# return asynchronous_deterministic_update(...)
def main():
get_table()
# simulate([0,0,0,0])
if __name__ == "__main__":