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. :)
Hey, I've been blacklisted at casinos for doing that, you insensitive clod!
Nice, post about this when there's only 3 days left to submit your scripts...
Just a word to the wise, the deadline for submission to this contest is February 29th. Clearly it's possible to write this type of script in a short period of time but for hobby-type programming contents, perhaps it would be more worthwhile to get this contest posted a bit before the deadline?
I hate liberals. If you are a liberal, do not reply.
No matter what you do, it seems the winner will still have a little luck. Sure you can count card, but that just helps your odds. If you can figure out how to program luck then you definitely should win.
-Jackson
Looking around the web, and in my inbox, I see a total lack of anything like an online casino. Now that everyone has been told how to do php blackjack, maybe someone will get off the ball and fill in this much-needed online niche! Way to go!
Counting cards dosent really help you untill atleast half way through the deck. Hence why most good cheats will bet the minimum every hand and count the cards as they play, then bring in another player to bet the max while relying on signals from the player who has the count.
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, 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.
symetrix. We are building a religion, a limited edition.
Count cards .. Count cards .. K-Mart sucks .. Who's on first .. Count cards .. Fly Quantas we never crash .. K-Mart sucks .. There are 1002 toothpicks on the table .. memorise phone book A-L .. who's on first .. count cards...
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.......
...an excellent driver... definitely an excellent driver... Bang! 97X, the power of Rock'n'Roll...
It's a known fact that when playing blackjack that high cards favour the player and low cards favour the dealer.
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 cards. Your counter would be set to a value of -2. Then 3 more cards are dealt that are all low cards. Your counter would now be +1. The higher the counter is the higher your bet should be for the next hand. Vice versa if the counter is negative.
The first few hands won't be very accurate, but towards the end of the deck(s) if the count is very high or very low, it should be a big indicator on how your odds are for the last hands.
Due to a pile of work I have to get done and the short notice about this game I can't test my theory...but it would be cool if someone took this idea and tried it out and posted back here whether it worked or whether it sucked!
-Pat