Play Blackjack with PHP 28
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. :)
Count cards? (Score:5, Funny)
Good Timing (Score:5, Funny)
Deadline is fast approaching (Score:4, Insightful)
Warning to those who will enter (Score:5, Informative)
Re:Warning to those who will enter (Score:5, Interesting)
Re:Warning to those who will enter (Score:4, Insightful)
I wonder if they're just doing an "else if" in the rules even if it's a logic path which can never even be encountered to begin with.
Re:Warning to those who will enter (Score:3, Informative)
Re:Warning to those who will enter (Score:3, Informative)
Re:Warning to those who will enter (Score:1)
Durr. Of course it's a win for the house, even if one person is bust, but.... the dealer still has to deal himself unless the whole table busts.
Wow.
not a good test (Score:1)
-Jackson
Re:not a good test (Score:5, Insightful)
The luck in this game is whether or not the deals that everyone gets are the type of deals that your scripts handles well.
So based on this, I think the winning strategy is the following:
Write a script that will do very well against a certain kinds of draws, and poorly against others. This would be a poor strategy if you were playing for money, and got to keep the net, but that isn't the game. The game here is that if you do the best (or one of the best) you win, and everything else loses. So losing badly isn't any worse than doing well but not the best. So take advantage of this by writing an aggresive strategy that will lose on most draws, but is sure to win on some. This is much better than writing a conservative script that will do well on any draw, but will always lose to whichever aggressive script happened to hit on the particular draw that was used.
When they run the contest, most of the entries will play a conservative strategy, and end up in a nice bell curve around a reasonable return. But the winner will be some off the wall script that does something crazy that happened to pay off against the draw they used.
How crazy it will take to win will of course depend on the number of entries.
You can be a sure winner if you get enough friends to enter with different aggresive strategies to cover all possible draws.
I wish I wasn't too busy to do it myself
- Funbobby
Re:not a good test (Score:1)
Re:not a good test (Score:1, Informative)
Once you know the odds on the best play to make, in the end if you play that best way every
This is great! (Score:5, Funny)
Re:This is great! (Score:1)
Re:This is great! (Score:2)
Things to ponder (Score:5, Insightful)
I'm not saying player swapping is nessisary in a PHP implementation, but anyone working on this should not rely on the count data untill atleast half the cards are gone. Which will leave another loophole for the programmer to account for: there can be anywhere from 1 to 10 decks.
A good blackjack player (not just a cheat) can not only count cards, but intimately knows their favorite version of the blackjack odds table [homeip.net], and most importantly how to bet to minimize the risk to their seed money and maximize profits when the cards are in their favor.
Another thing that must be compensated for is the greatest tool in any players bag of tricks. The ability to just get up and walk away. If the cards aren't treating you right, move to another table. This dosen't work in tournements, but is a great tactic for limiting your losses.. which is casino speak for "winning".
Oh, and when testing, make sure your shuffle is truely random [random.org].
Re:Things to ponder (Score:3, Informative)
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
Re:Things to ponder (Score:2, Informative)
Count cards (Score:3, Funny)
Re:Count cards (Score:1)
Re:Count cards (Score:1)
82,
82,
82
246 total.
Uh oh, fifteen minutes to Judge Wapner.
Counting Cards Not a Big Help (Score:3, Insightful)
Bad hint.
Card counting will be of limited value, since:
- the number of decks you are playing is so low compared to the variance of the game that you are not even close to the "long run". Luck will dominate.
- the game has some non-standard rules (i.e. push if you and dealer both bust; player blackjack loses to dealer blackjack) that most strategies out there are not correct for the game.
Given the low number of hands to play, you should exploit tournament strategies, not card counting.
Posted anonymously since I don't want to end up in the Griffin book.......
Counting cards (sort of) would work... (Score:2)
I wish I had read this earlier and had the time to code a program using a simple algorithm that I think would work great...regardless of how many decks there are.
I think if someone were to use a constant integer (starting at a value of 0) that either gets incremented or decremented depending upon each card played you could adjust your bet accordingly.
Say the first 2 cards dealt out are face car