Logic problem: need better logic for desired thruth table.

Grant Edwards invalid at invalid.invalid
Thu May 28 18:11:36 EDT 2015


On 2015-05-28, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2015-05-28, Skybuck Flying <skybuck2000 at hotmail.com> wrote:
>
>> I tried logic below... but funny enough it failed, now I feel like a
>> noob lol and share this funny little fail logic with you.
>>
>> Can you improve/fix the logic ?
>
>> # 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))
>
> I don't see why you think that's the desired logic, since it doesn't
> match your truth table or your test.
>
>> def TestLogic( BotWaitForCooldown, CooldownDetected ):
>> return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)
>> # this logic is flawed, please improve logic.
>
> def TestLogic( BotWaitForCooldown, CooldownDetected ):
>     return not ((not BotWaitForCooldown) and CooldownDetected)
>
> works for me...    

While I think that's the most "obvious" solution and can be verified
by inspection: there's only out input state that is "false", so write an expression
for that one state and invert it.

However, you can apply De Morgan's law to simplify it:

       not ((not BotWaitForCooldown) and CooldownDetected)
       
is same as

       (BotWaitForCooldown or (not CooldownDetected))

-- 
Grant Edwards               grant.b.edwards        Yow! Do you have exactly
                                  at               what I want in a plaid
                              gmail.com            poindexter bar bat??



More information about the Python-list mailing list