Interestingly enough the shortest I have seen so far is ***:
def TestLogic( BotWaitForCooldown, CooldownDetected ):
# return BotWaitForCooldown or ((not BotWaitForCooldown) and
CooldownDetected) # this logic is flawed, please improve logic.
# return (not ((not BotWaitForCooldown) and CooldownDetected)) # fixes it.
# return (BotWaitForCooldown or (not CooldownDetected)) # optimization but
looks weird :)
return (BotWaitForCooldown >= CooldownDetected) # *** even shorter, wow
cool, thanks to Jussi Piitulainen
Apperently there is a short-coming/flaw in the reasoning about boolean
logic, if boolean logic is converted to numbers/0/1 and comparisions allowed
then apperently there are even shorter forms ?!? Am I correct ? Or am I
missing something ? Perhaps branching don't count ? Hmmmm..... Is this
branching ? Or something else... hmmm.... I think the comparison result
could be used without requiring branching... so I think my conclusion might
be correct.
Bye,
Skybuck.
"Skybuck Flying" wrote in message
news:7b1ef$556792ab$5419aafe$58...@news.ziggo.nl...
Ok, problem solved for now, it seems:
I used video tutorial method and inverted it for the false case ;)
But anyway... I would not only need a "thruth table to logic/boolean
operations converter" but also a "boolean operations optimizer" ;)
# loop has to run if:
# while DesiredResult==True:
# Desired truth table for BotWaitForCooldown and CooldownDetected
# BotWaitForCooldown: CooldownDetected: Desired Result:
# False False True
# False True False
# True False True
# True True True
# desired/suiting logic:
# (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))
def TestLogic( BotWaitForCooldown, CooldownDetected ):
# return BotWaitForCooldown or ((not BotWaitForCooldown) and
CooldownDetected) # this logic is flawed, please improve logic.
return (not ((not BotWaitForCooldown) and CooldownDetected)) # fixes it.
if TestLogic( False, False ) == True:
print "test 1 ok"
else:
print "test 1 failed"
if TestLogic( False, True ) == False:
print "test 2 ok"
else:
print "test 2 failed"
if TestLogic( True, False ) == True:
print "test 3 ok"
else:
print "test 3 failed"
if TestLogic( True, True ) == True:
print "test 4 ok"
else:
print "test 4 failed"
Bye,
Skybuck.
--
https://mail.python.org/mailman/listinfo/python-list