Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Something I've long been curious about:

    Mel finally gave in and wrote the code,
    but he got the test backwards,
    and, when the sense switch was turned on,
    the program would cheat, winning every time.
This doesn't sound like the sort of bug that occurs because you get a test backwards. Making a blackjack program that wins every time, and one that loses every time, seem like very different beasts. So what mistake did Mel make?


The manual for the game says:

  If SENSE SWITCH 32 is depressed, there is a better than normal chance
  of an ace being dealt as the player's first card.
Presumably the story didn't get that quite right. Sadly the code hasn't turned up.


It seems pretty identical to me. In Blackjack, the easiest way to make someone win is to give them 21, and make sure no one else gets 21.

So if the pseudocode is something like:

    if cheat_switch:
        if active_player == "COMPUTER": #this should be "HUMAN"
            make_current_player_get_21()
        else:
            make_current_player_get_20_or_busts()
Then the computer will always get 21, and the human player will get 20. Assume for the moment that it deals with dealing multiple cards for both the human and computer; this can be done, but isn't worth getting into.

And this could all be switched in the `active_player` check.


I always understood it as intentional on Mel's part.


Along the same lines as some of the other responses, it's possible that the "test" in question was testing whether the affected player was the human or the computer; getting that particular test backwards would certainly have the described effect.


Deliberately ignoring the instructions :)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: