Handling Boolean Unknowns

Discussion in 'Suggestions' started by sipainting, Nov 20, 2023.

  1. sipainting

    sipainting Virgin CHYOA Backer

    So, it's clear that Booleans can be "True" "False" and "undefined".

    Originally, I thought that all "undefined" also evaluated to "False" - but apparently that's not the case. Undefined != False.

    Therefore, I recommend having three buttons for checking booleans:

    [ CHECK-MARK ] [ X ] [ ? ]

    Where a user can check in the conditions for "undefined" booleans.

    FURTHER, I would recommend allowing for multiple buttons to be selected. In other words, you can select BOTH the [ X ] and the [ ? ] which would pass the condition if the boolean is EITHER [ X ] or [ ? ].

    Thanks.

    Alternatively, the story could have a setting which says: "Treat all boolean unknowns as false"
     
  2. gene.sis

    gene.sis CHYOA Guru

    Well, if a variable isn't set, the respective statement or condition fails.
    This is the same behavior as with other variable types.
     
  3. sipainting

    sipainting Virgin CHYOA Backer

    Agreed, but it's a pain to have to initialize all my booleans to "False" ahead of time (in some previous page) in order to test them later for "Not True". I have a lot of variables (some 50-60) in my story.
     
  4. gene.sis

    gene.sis CHYOA Guru

    Well, there might be ways in the future that allow setting a variable if it isn't set yet.
    I don't think that checking for undefined is the way to go.

    For non-boolean variables, there is already a workaround.
    So you could add a score change +0 for the variable in question. That doesn't change the value of the existing variable but would create it if it doesn't exist yet. The value of the variable would then be 0.

    It would also be possible to convert the boolean variable into a non-boolean variable and initialize it if it doesn't exist yet. (FALSE -> 0; TRUE -> 1; in Conditions: 0 -> FALSE; <0 -> TRUE; >0 -> TRUE)
    But you can't convert it back, so it won't be shown as check/times in the reader's Score.