Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions hashes/chaos_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@


def push(seed):
"""
Push data into the chaos machine buffer.

Updates the buffer space and parameters space using chaotic dynamics
based on the input seed value.

Args:
seed: Input value to push into the chaos machine

>>> reset()
>>> initial_time = machine_time
>>> push(12345)
>>> machine_time == initial_time + 1
True
>>> len(buffer_space) == m
True
>>> all(0 <= x < 1 for x in buffer_space)
True
"""
global buffer_space, params_space, machine_time, K, m, t

# Choosing Dynamical Systems (All)
Expand Down Expand Up @@ -73,6 +92,20 @@ def xorshift(x, y):


def reset():
"""
Reset the chaos machine to initial state.

Resets buffer space to initial values K, clears parameters space,
and resets machine time to 0.

>>> reset()
>>> buffer_space == K
True
>>> machine_time
0
>>> len(params_space)
5
"""
global buffer_space, params_space, machine_time, K, m, t

buffer_space = K
Expand Down
Loading