an Array-based binary counter with functions designed for cellular automata experimentation
pip install BinaryCounters
BC1 = BinaryCounter(0,10)
BC2 = BinaryCounter(10,10)
print(BC1.val()) #[0,0,0,0,0,0,0,0,0,0] left if most significant digit, right is least
print(BC2.val()) #[0,0,0,0,0,0,1,0,1,0]
BC1.increase(1)
BC2.increase(386)
print(BC1.val()) #[0,0,0,0,0,0,0,0,0,1]
print(BC2.val()) #[0,1,1,0,0,0,1,1,0,0]
BC1.BIT_OP(BC2,"OR")
print(BC1.val()) #[0,1,1,0,0,0,1,1,0,1]
print(BC2.val()) #[0,1,1,0,0,0,1,1,0,0]
def randomFn(index,bit,b):#just a random equation that spits out 0,1
return ((bit+b)*(index*b+1))%2
BC3 = BinaryCounter(15,5) #[0,1,1,1,1]
BC1.R_BIT_OP(BC3,randomFn)
print(BC1.val()) #[1,0,0,0,0,0,0,0,1,1]
#to have a smaller array act on a larger:
#use W_BIT_OP and pass in the logical function
#give it the binary (any array of bits)
BC1.W_BIT_OP(BC3, OR) # OR these arrays together, and since BC3 is smaller, loop over until you cover all elements of BC1
#use S_BIT_OP to
BC1.S_BIT_OP(BC3, OR) # OR these arrays together, and since BC3 is smaller, so it returns BC1 partially unmodified