WishUnderflow
-
This post did not contain any content.
-
This post did not contain any content.
wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?
-
This post did not contain any content.
"Subtract 4 wishes"
-
wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?
wrote on last edited by [email protected]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.
-
wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?
Genie reduced number of wishes to 0. But by doing so he granted one of the wishes, so it became -1 (255).
-
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.
This is actually genius
-
This post did not contain any content.
I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.
-
I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.
If there's parallelism/async involved, then there definitely is an argument to decrement first, execute later. Otherwise you could make a wish for the genie to just wait for an hour and then make as many wishes as you want within that hour.
-
This post did not contain any content.
You fool, you've unleashed ghandi's thermonuclear rage!
-
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.
Yeah, but what if the counter gets decremented before the wish gets granted, huh?
-
Yeah, but what if the counter gets decremented before the wish gets granted, huh?
I love being a nerd
-
I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.
I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place.
Why? Shouldn't you decrement the limited resource the user has access to in case the thing you are doing fails?
-
If there's parallelism/async involved, then there definitely is an argument to decrement first, execute later. Otherwise you could make a wish for the genie to just wait for an hour and then make as many wishes as you want within that hour.
But how can you decrement a future dated wish, since you can't guarantee nothing will happen that prevents the genies ability from executing said wish? E.g. i mean like telling the Genie to do something 5 days from now, not your example which would begin immediately after making said wish.
-
This post did not contain any content.
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.
-
This post did not contain any content.wrote on last edited by [email protected]
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.
-
But how can you decrement a future dated wish, since you can't guarantee nothing will happen that prevents the genies ability from executing said wish? E.g. i mean like telling the Genie to do something 5 days from now, not your example which would begin immediately after making said wish.
You decrement the wish counter first, execute the action (which includes waiting those 5 days), and if it fails you increment the counter back. Something like this:
wishes = wishes - 1; executeWish(wish).unwrap_or_else(|_| { wishes = wishes + 1; })?
This way if the action fails in the future, you get a wish back and can ask something else.
-
This post did not contain any content.
Now make it 2.5 wishes. Now 0.9. Now 999.
-
Yeah, but what if the counter gets decremented before the wish gets granted, huh?
I would assume this to be the case since you cannot un-utter a wish—once you say it, it is counted as a wish before it's fulfilled.
If the counter is decremented only after the wish is fulfilled, then this means you can go back on wishes because they don't count until they're fulfilled, which goes against the lore.
-
Now make it 2.5 wishes. Now 0.9. Now 999.
Found the QA tester.
-
Now make it 2.5 wishes. Now 0.9. Now 999.
After you made it 0.9 you no longer have enough wishes left.