#=========================================================
import os
import random
T=1.0
F=0.0
PossibleStates= [0.0, 0.05, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45,
0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00]
#=========================================================
def OrganismAnd(in1, in2):
if (in1==F) and (in2==F): return F
elif (in1==T) and (in2==F): return F
elif (in1==F) and (in2==T): return F
elif (in1==T) and (in2==T): return T
else: return None
# end function
#=========================================================
# Main Loop
while 1:
in1=random.choice(PossibleStates)
in2=random.choice(PossibleStates)
output = OrganismAnd(in1,in2)
if output == T:
print in1,in2,"shutdown" # os.system.shutdown()
break
elif output == F:
print in1,in2,"shutdown" # os.system.shutdown()
break
else:
print in1,in2,"Okay" # keep going
continue
# end while
#=========================================================
This program has one neuron-like function, labeled 'Organism AND'. This simulates an AND-gate neuron that can distinguish uncertainty from certainty. When both of its inputs are exactly FALSE it says FALSE. When one is TRUE and the other is FALSE, it says FALSE. When both are exactly TRUE it says TRUE. Those outputs are standard AND responses. The function also handles uncertainty. When either input is between TRUE and FALSE, it gives an uncertain answer. ('None' in Python is the NULL value.)
The main loop below the function simply feeds the Organism a set of random inputs, simulating the various experiences of life. I've restricted the 'variety' of these random inputs to 20 steps from FALSE to TRUE so it reaches a conclusion in a satisfyingly short amount of time. (About one second for each run.)
When the main loop gets an indefinite response from the Organism, it keeps going. No problem. When it gets a definite TRUE or FALSE from the organism, it shuts down.
Note that this little program doesn't REALLY shutdown the computer; it just ends its own life. But you could decomment those lines.Labels: Natural law = Sharia law, Real World Math
The current icon shows Polistra using a Personal Equation Machine.