Skip to content

Commit 7520f65

Browse files
committed
Updated chaos machine algorithm
1 parent 7ce998b commit 7520f65

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

hashes/chaos_machine.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1-
"""example of simple chaos machine"""
1+
"""example of simple chaos machine
2+
Simple Chaos Machine refers to computational model that demonstrates chaotic behavior.
3+
It takes input values, applies a chaotic transformation using control theory principles, and generates
4+
unpredictable output ( meaning small changes in input lead to drastically different outputs over time),"""
5+
6+
""" Chaos Machine (K, t, m)
7+
K --> Initial values for the buffer space.
8+
t --> Time length for evolution (how long transformations happen).
9+
m --> Number of elements in the chaotic system."""
210

3-
# Chaos Machine (K, t, m)
411
K = [0.33, 0.44, 0.55, 0.44, 0.33]
512
t = 3
613
m = 5
714

8-
# Buffer Space (with Parameters Space)
15+
# Buffer Space (with Parameters Space) --> Stores values undergoing chaotic transformation.
916
buffer_space: list[float] = []
17+
18+
# Stores parameters controlling the transformation.
1019
params_space: list[float] = []
1120

12-
# Machine Time
21+
# Machine Time --> Keeps track of execution time.
1322
machine_time = 0
1423

15-
24+
"""The push() function updates the buffer_space and params_space by applying chaotic transformations
25+
based on control theory. It modifies all values in the buffer_space using an orbit change and trajectory change formula,
26+
which ensure values to stay within controlled chaotic limits. Finally, it increments machine_time."""
1627
def push(seed):
1728
global buffer_space, params_space, machine_time, K, m, t
1829

@@ -39,6 +50,9 @@ def push(seed):
3950
machine_time += 1
4051

4152

53+
"""The pull() function generates a chaotic pseudo-random number using a logistic map transformation
54+
and the Xorshift algorithm. It updates buffer_space and params_space over multiple iterations, ensuring chaotic evolution.
55+
Finally, it selects two chaotic values, applies Xorshift, and returns a 32-bit random number."""
4256
def pull():
4357
global buffer_space, params_space, machine_time, K, m, t
4458

@@ -99,4 +113,4 @@ def reset():
99113
print(f"{format(pull(), '#04x')}")
100114
print(buffer_space)
101115
print(params_space)
102-
inp = input("(e)exit? ").strip()
116+
inp = input("(e)exit? ").strip()

0 commit comments

Comments
 (0)