From 7520f65a2afeac251a48c4546db1b92b8d8ca206 Mon Sep 17 00:00:00 2001 From: Saba633 Date: Thu, 13 Mar 2025 22:06:37 +0500 Subject: [PATCH 1/2] Updated chaos machine algorithm --- hashes/chaos_machine.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/hashes/chaos_machine.py b/hashes/chaos_machine.py index d2fde2f5e371..24cd9626a4de 100644 --- a/hashes/chaos_machine.py +++ b/hashes/chaos_machine.py @@ -1,18 +1,29 @@ -"""example of simple chaos machine""" +"""example of simple chaos machine + Simple Chaos Machine refers to computational model that demonstrates chaotic behavior. + It takes input values, applies a chaotic transformation using control theory principles, and generates + unpredictable output ( meaning small changes in input lead to drastically different outputs over time),""" + +""" Chaos Machine (K, t, m) + K --> Initial values for the buffer space. + t --> Time length for evolution (how long transformations happen). + m --> Number of elements in the chaotic system.""" -# Chaos Machine (K, t, m) K = [0.33, 0.44, 0.55, 0.44, 0.33] t = 3 m = 5 -# Buffer Space (with Parameters Space) +# Buffer Space (with Parameters Space) --> Stores values undergoing chaotic transformation. buffer_space: list[float] = [] + +# Stores parameters controlling the transformation. params_space: list[float] = [] -# Machine Time +# Machine Time --> Keeps track of execution time. machine_time = 0 - +"""The push() function updates the buffer_space and params_space by applying chaotic transformations +based on control theory. It modifies all values in the buffer_space using an orbit change and trajectory change formula, +which ensure values to stay within controlled chaotic limits. Finally, it increments machine_time.""" def push(seed): global buffer_space, params_space, machine_time, K, m, t @@ -39,6 +50,9 @@ def push(seed): machine_time += 1 +"""The pull() function generates a chaotic pseudo-random number using a logistic map transformation +and the Xorshift algorithm. It updates buffer_space and params_space over multiple iterations, ensuring chaotic evolution. +Finally, it selects two chaotic values, applies Xorshift, and returns a 32-bit random number.""" def pull(): global buffer_space, params_space, machine_time, K, m, t @@ -99,4 +113,4 @@ def reset(): print(f"{format(pull(), '#04x')}") print(buffer_space) print(params_space) - inp = input("(e)exit? ").strip() + inp = input("(e)exit? ").strip() \ No newline at end of file From 207951d12f09474ba53c2d8a3b3fd393841ba846 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:10:26 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- hashes/chaos_machine.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hashes/chaos_machine.py b/hashes/chaos_machine.py index 24cd9626a4de..f6ce6f863b72 100644 --- a/hashes/chaos_machine.py +++ b/hashes/chaos_machine.py @@ -1,7 +1,7 @@ """example of simple chaos machine - Simple Chaos Machine refers to computational model that demonstrates chaotic behavior. - It takes input values, applies a chaotic transformation using control theory principles, and generates - unpredictable output ( meaning small changes in input lead to drastically different outputs over time),""" +Simple Chaos Machine refers to computational model that demonstrates chaotic behavior. +It takes input values, applies a chaotic transformation using control theory principles, and generates +unpredictable output ( meaning small changes in input lead to drastically different outputs over time),""" """ Chaos Machine (K, t, m) K --> Initial values for the buffer space. @@ -22,8 +22,10 @@ machine_time = 0 """The push() function updates the buffer_space and params_space by applying chaotic transformations -based on control theory. It modifies all values in the buffer_space using an orbit change and trajectory change formula, +based on control theory. It modifies all values in the buffer_space using an orbit change and trajectory change formula, which ensure values to stay within controlled chaotic limits. Finally, it increments machine_time.""" + + def push(seed): global buffer_space, params_space, machine_time, K, m, t @@ -50,9 +52,11 @@ def push(seed): machine_time += 1 -"""The pull() function generates a chaotic pseudo-random number using a logistic map transformation -and the Xorshift algorithm. It updates buffer_space and params_space over multiple iterations, ensuring chaotic evolution. +"""The pull() function generates a chaotic pseudo-random number using a logistic map transformation +and the Xorshift algorithm. It updates buffer_space and params_space over multiple iterations, ensuring chaotic evolution. Finally, it selects two chaotic values, applies Xorshift, and returns a 32-bit random number.""" + + def pull(): global buffer_space, params_space, machine_time, K, m, t @@ -113,4 +117,4 @@ def reset(): print(f"{format(pull(), '#04x')}") print(buffer_space) print(params_space) - inp = input("(e)exit? ").strip() \ No newline at end of file + inp = input("(e)exit? ").strip()