• expatriado@lemmy.world
    link
    fedilink
    arrow-up
    28
    ·
    5 days ago

    wouldn’t 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?

    • Khanzarate@lemmy.world
      link
      fedilink
      arrow-up
      38
      ·
      edit-2
      5 days ago

      You’re correct but you have an off by 1 error.

      First, the genie grants the wish.

      NumWishes=0;

      Then, having completed the wish, the genie deducts that wish from the remaining wishes.

      NumWishes–;

      And to complete the thought,

      Lastly, the genie checks if the lampholder is out of wishes

      If(NumWishes==0) {…}

      (255==0) evaluates to False, so we fall past that check.

        • Szyler@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          2 days ago

          You have 3 wishes.

          First wish: I wish my last wish would count as me consuming two wishes. Second wish: I wish to have 0 wishes remaining.

          First wish puts you down one wish, so ending at 2. Second wish removes one wish, so at one, then wish happens putting you at 0,

          then because this second wish now becomes your last, as you have 0 remaining, the first wish then takes effect and consumes another wish, putting you to - 1 and overflowing.

        • Khanzarate@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          5 days ago

          Genie in the OP image would’ve said “OK you now have 0 wishes”.

          Since he said 255, my interpretation is a valid solution.

          Of course, if we’re talking hypothetical wish gaining prevention methods, I’d just have a check before,

          previous_wishes = wishes;

          {Do all the wish things. wishes ends up with a 255 because of our shenanigans}

          If(wishes>=previous_wishes) wishes = previous_wishes-1;

          ;If the current number of wishes isnt less than the old number of wishes, set it to the old number and subtract 1

          If(wishes==0) {/*TODO: write function to end wish giving sequence*/}

  • palordrolap@fedia.io
    link
    fedilink
    arrow-up
    13
    ·
    5 days ago

    Then you find out the genie uses a signed data value and you now owe him a wish. You’re not granted magic. You’re compelled to grant the wish. The only restrictions on the genie’s wish is that it must be within your (soft, squishy) mortal power.

    I can imagine you being reset to the point of the genie’s wish every time you die (naturally or otherwise) without succeeding. This could well turn into a Groundhog Day type situation.

  • TheFogan@programming.dev
    link
    fedilink
    English
    arrow-up
    12
    ·
    5 days ago

    Wouldn’t it depend on the order of operations, you’d think even vibe coding a genie would still have the sense to lower the counter before granting the wish.

    So logically

    Wishes = 3

    Make wish count zero.

    *wish used, wish count 2

    Wish applied, wish count 0

    • Feathercrown@lemmy.world
      link
      fedilink
      English
      arrow-up
      6
      ·
      5 days ago

      It seems logical to decrement after the wish is granted, imo. Just causes issues in this particular case…

      • TheFogan@programming.dev
        link
        fedilink
        English
        arrow-up
        5
        ·
        5 days ago

        Dunno, I know enough duplicate exploits in games to know giving the effect then reducing the item, is a pretty common source of duplication hacks/bugs.

        I guess it comes down to which is the designer is more afraid of happening, the chance of a wish being expended but not granted, or granted without expending.

        Then again based on disney’s aladin, tricking the genie into rescuing him without using a wish, it does seem practical to assume that the genie errors on the side of granting without expending.

  • sun_is_ra@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    5 days ago

    Should’ve been “make -1 wishes” 0 is 0

    Edit:oh I get it. First the gene fullfill the wish then subtract one from the 0 wishes.

  • Jankatarch@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    4 days ago

    Id they were optimized to use unsignrd they would be optimized to use 2 bits for 3 wishes rather than 8. You have 3 wishes left.