As I had a blast working on the original KOTH challenge, I wanted to come up with another one. For me, the fun of these AI challenges is in refining a comparatively simple bot which plays a very simple game subtly. Due to the probabilistic nature of card games, I think that blackjack could be an interesting KOTH game just like TPD.
Rules Regarding Cards & the Deck
- Bots play at tables of four (4) competitors and one (1) dealer
- One (1) shoe (a shuffled deck) is shared by all players and the dealer until it is exhausted, at which point a new randomly shuffled deck will be added and play will continue. The bots ARE NOT (at present) NOTIFIED of the addition of this new deck. Such notification may be added if lack of this feature causes sufficient distress/trouble.
- There is a buy-in of 10 per round, and cards are free
- Perfect/ideal hand has a score of 21
- All face cards have a value of 10
- All numeric cards are worth their number
- Aces are worth 11 or 1. this will be dealt with automatically by the framework, not the bots.
- As per the rules, all players' cards are dealt face-up and are visible. One of the dealer's cards is face-down and the other is face-up.
- Scores in excess of 21 which use an ace as 11 force the ace to reduce in value to 1
- scores in excess of 21 which cannot be coerced below the threshold of 21 "bust" the bot
- The dealer draws until he busts, or excedes a score of 17 at which point he is forced to stand
Betting and Chips
- At the start of each round, a buy-in of 10 is charged, so there is a minimum stake of 10, and a minimum bet of 1. NOTE - the bet is the absolute value of the bet argument, so don't bother trying negative bets.
- Bots which cannot afford the buy-in are removed from the contest
- When making bets, bots cannot bet more than the chips they have
- If the bet is possible, the chips bet are emmidiately removed from the bot and added to the stake
- Winning a bet gives the bot 2x chips bet. However because the bet is subtracted from the bot's chips, the bot breaks even and then wins 1x the bet.
- Bots win bets only if their score is greater than that of the dealer
- When the game starts, each player is iteratively dealt one card, and has the $10 buy-in fee/minimum bet subtracted from their chips.
- The dealer draws
- A second pass is made, and another card is dealt to all players.
- The dealer draws
- Then (in the same order as they were dealt to) each bot is executed as described in the "Programmer's Interface" section and must make a move or stand. Betting is considered a move. NOTE THAT BETTING DOES NOT AFFECT BOTS' ABILITY TO MAKE FURTHER MOVES. It is very possible to bet and then draw a card, and it is possible to draw multiple cards and them bet before standing.
- When all the bots have busted or stood, the dealer plays to its threshold of 17
- The scores of the bots are then compared to that of the dealer, bets are won and lost
Is considered to constitute five (5) hands. In-between hands, the list of contestants is sorted to remove players and then further processed to ensure that all the bots play the same number of hands (a provision for the fact that the number of entries will not devide evenly among four-bot tables).
Programmer's Interface and Legal Moves
As documented in the CardShark file:
# DOCUMENTATION # INPUT SPECIFICATION # $ ./foo.bar <hand-score> <hand> <visible cards> <stake> <chips> # <hand-score> is the present integer value of the player's hand. # <hand> is a space-free string of the characters [1-9],A,J,Q,K # <visible cards> every dealt card on the table. when new shoes are brought # into play, cards drawn therefrom are simply added to this list # NOTE: the first TWO (2) cards in this list belong to the dealer. # one however will be "hidden" by a "#". the other is visible. # !!! THE LIST IS CLEARED AT THE END OF HANDS, NOT SHOES !!! # <stake> the number of chips which the bot has bet this hand # <chips> the number of chips which the bot has # SAMPLE INPUT # $ ./foo.bar 21 KJA KQKJA3592A 25 145 # # OUTPUT SPECIFICATION # "H"|"S"|"D"|"B" (no quotes in output) # "H" HIT - deal a card # "S" STAND - the dealer's turn # "D" DOUBLEDOWN - double the bet, take one card. FIRST MOVE ONLY # "B 15" BET - raises the bot's stakes by $15.
As (now) documented in the Cards file:
# class CARD # card is a container for representing paper playing cards in # otherwise fairly functional programming. # letter() # gets the letter used to identify the card in a string # LETTER MAPPINGS # Ace : 'A' # Two : '2' # Three : '3' # Four : '4' # Five : '5' # Six : '6' # Seven : '7' # Eight : '8' # Nine : '9' # Ten : 'T' # Jack : 'J' # Queen : 'Q' # King : 'K' # "Hidden": '#'
The source code for the scoring system is HERE
#!/usr/bin/env python import sys s = sys.argv if int(s) < 17: print "H" else: print "S"
At present, Java, c/c++, Python and Lisp are supported. A reasonable effort will be made to include submissions in other languages, but remember that the final contest will be run on a Linux box.
The winner would be the author of the bot which consistently accrued the most chips over a yet-to-be determined number of tables and rounds.
The winner will be announced on June 3rd, but the announcement may be delayed if there are still submissions coming in. Contest extended indefinitely.