Slashdot Mirror


Play Blackjack with PHP

Zack Coburn writes "The latest Codewalkers PHP Coding Contest invites PHP programmers to compete by creating a PHP script that interfaces with a special PHP library to play the game of Blackjack. Judging will happen as follows: 'A number of random decks will be generated, for each random rules will be used. Each script will then play all these decks, so each script will play under exactly the same conditions. In the end, the sum of all the money gained will determine the winner. In case of a tie, the running time will be the tie-breaker.' Some of the sixteen prizes include Cerberus Encoder, PHPEd, Macromedia Studio MX, SourceGuardian Pro, and Zend Studio." Here's a hint: count cards. :)

5 of 28 comments (clear)

  1. Warning to those who will enter by vslashg · · Score: 5, Informative
    From the contest rules:
    If both you and the dealer bust, the hand is a tie.
    I don't know what game that is, but it's not casino blackjack. If your plan is to quickly translate some blackjack code you've already written into PHP, you're going to have to compensate for their misunderstanding of the real rules.
    1. Re:Warning to those who will enter by karnal · · Score: 2, Informative

      Most blackjack rules I've seen have a "dealer must hit to 17", which means the dealer can't just sit there with a 2 showing and not hit, unless the whole table (players) are bust...

      --
      Karnal
    2. Re:Warning to those who will enter by notsoclever · · Score: 2, Informative

      That's only if the player hasn't busted already. If the player busts, it's an automatic win for the house.

      --
      There are 10 kinds of people: ones who understand ternary, ones who don't, and ones who think this joke is about binary
  2. Re:Things to ponder by T-Ranger · · Score: 2, Informative
    The vast majority of counting strategies are based on adjusting your bet. As a counting player, you always play the 'basic strategy', and adjust your bet according to your count.

    Well, almost 'always', anyway. If your in third base, holding a 12 against a dealers 3, and the last 7 cards have been faces, then a hit would be a good thing, even though it is against basic strategy.

    The other exception is if you are keeping a side count of faces, you can use that information to choose to take insurance. Playing basic strategy, insurance (or even money on a BJ) is always a bad idea.

    On your second to last point, I wounder how well a program : "sitdown(); bed(0); leave(); " would do ....

  3. Re:Things to ponder by allstarska · · Score: 2, Informative

    I don't know about the math behind it - but I have read and heard that shuffling is not truely random.