Untitled
unknown
plain_text
a year ago
1.1 kB
7
Indexable
import numpy as np def cooldown(signal, cooldown=60): # Convert the signal column to a NumPy array if it's not already signal_array = np.array(signal) # Initialize the cooldown counter to 0 cooldown_counter = 0 # Initialize the signal to propagate as None (no signal to propagate initially) signal_to_propagate = None for i in range(len(signal_array)): if signal_array[i] in [1, -1] and cooldown_counter == 0: # If a signal is found and we are not currently in a cooldown, # set the cooldown counter and remember the signal to propagate cooldown_counter = cooldown signal_to_propagate = signal_array[i] elif cooldown_counter > 0: # If we are within the cooldown period, propagate the remembered signal signal_array[i] = signal_to_propagate cooldown_counter -= 1 # Reset the signal to propagate if the cooldown has finished if cooldown_counter == 0: signal_to_propagate = None return signal_array
Editor is loading...
Leave a Comment