Code'em Poker
- Introduction
- Structure
- Terminology
- Instructions
- Poker Rules
- Timeline
Introduction
“The commonest mistake in history is underestimating
your opponent; it happens at the poker table all the time.” - David ShoupCard games have been one of the most exciting and relishing leisure time activity for one and all. Hearts, Bluff, Black Jack, Poker, Rummy have been all time favorites.
Amongst all, Poker is one such card game which is embellished by mindful tactics, shrewd judgements and thrilling competition.
How amazing would it be when such a remarkable game would be augmented by the tentacles of coding to entrap the money from opponents. Here's the opportunity for top coders all across the world to show their coding skills and lock heads with their opponents to join in the thrill at the Poker table.
Problem Statement
The teams have to submit codes. At a time, six codes will play the game of Poker.
Cash prizes worth INR 36,000 to be won.
Click Here to download the Problem Statement.
Register for Code'em Poker (non-students can also participate)
For further queries contact:
| Prateek Sondoule Manager, Events prateek.s@techfest.org Ph. +91 90223 09959 |
Shivam Agarwal Manager, Events shivam@techfest.org Ph. +91 97692 13023 |
Structure
Framework
The competition aims to provide an interface for codes of different teams to simultaneously play the famous card game ‘POKER’ against each other. The codes will be in the following languages :- C
- C++
- Java
- Perl
- Ruby
- Python
Note: In the entire documentation, ‘user’ refers to the team and ‘admin’ refers to the administrator. A part of the code will be submitted by the user and the rest will be created by the admin to help simulate and execute the entire game.
The cards will be represented by an integer. Look at the Terminology tab.
User Task
The user has to make a program named- Call: to match the amount currently bet by any other player higher than the team's money already in the pot. If no bet is initially made, call is similar to check.
- Fold: to cease playing in the current deal. The money bet in the current deal is lost.
- Raise: to raise the money over the current bet by a particular value which depends on different situations viz. preflop, postflop, post-fourth street, etc. and also on previous bets made in the current betting round.
- Post-showdown: This is not actually a decision, this is just to make out the strategies of fellow players by seeing their cards and comparing with the bets they have made during the game.
Orientation of Players
- Left : 2 is left to 1 i.e. 6,5,4,3,2,1 from extreme left to extreme right. Since the table is circular, 1 is to the left of 6.
- Right : 1 is right to 2 i.e. 1,2,3,4,5,6 from extreme right to extreme left. Since the table is circular, 6 is to the right of 1.
Text Files
To help the user know the entire course of game being played, he will be provided with some text files. Below is their description :- inputf.txt: this text file stores information about the following :
- card1: the integer representation of one hole card
- card2: the integer representation of the other hole card
- player: at a time, six teams will be simultaneously playing the game of Poker, so player is the position of the team among the six players. It is a number from 1 to 6. It will remain same in all the deals for a particular table.
- spent: its the money which the team has put in the current deal till now.
- deals_money.txt: this text file just stores the number of deals which have been played till now and the money left with the players before the starting of the current deal. One deal is completed after the showdown.
- deal.txt: this is the text file representing current deal. This text file gives the complete description of a particular deal.
- outputf.txt: the team has to enter its decision in this text file. Possible decisions and their output formats are :
- Call: The output value in such a case is the integer 0.
- Fold: The output value in such a case is the integer -10.
- Raise: The output value is the amount of money raised in integers.
- Post-Showdown: This matters only when the stage of the game is Show_Down. Teams need not output anything in this case. Even if some team writes anything in the oututf.txt file, it will be neglected.
All files will/should be in the current folder.
So, when the program is executed in the Show_Down stage, teams will update their help files which can help them in the next deal.
Editable permissions to files
All the files are not both readable and writable. The permissions goes as follows :- inputf.txt: only readable
- deals_money.txt: only readable
- deal.txt: only readable
- outputf.txt: readable and writable. The team has to write or return its decision in this file only.
The above files will be made by the administrator and will be in the same folder as the main program of the team. So, the teams can directly use the names of these files in their codes. The help files will be made by the teams only. These files can either be in the current folder or can be inside a new sub-directory created by the team in the current folder.
Format of Text Files
The text files are in the format so that it is easy and efficient to access the required data from them. Below is the format of the text files :- inputf.txt: represents the input given to a team to extract out its decision. The format is as follows :
12 37 2 400
- deals_money.txt: represents the current deal in play and the money, teams are left with at the start of the current deal. The format of the file is:
Deal 3 1 1800 2 1500 3 600 4 2100 5 1000 6 2000
- deal.txt: this is the text file representing the current deal.
Click to view the complete text file deal.txt
- An incomplete text file deal.txt:
Click here to view the incomplete text file deal.txt
Cards Terminology
| Image | Card | Representation | Image | Card | Representation |
| Two of Spade | 1 |
| Two of Heart | 27 |
| Three of Spade | 2 |
| Three of Heart | 28 |
| Four of Spade | 3 |
| Four of Heart | 29 |
| Five of Spade | 4 |
| Five of Heart | 30 |
| Six of Spade | 5 |
| Six of Heart | 31 |
| Seven of Spade | 6 |
| Seven of Heart | 32 |
| Eight of Spade | 7 |
| Eight of Heart | 33 |
| Nine of Spade | 8 |
| Nine of Heart | 34 |
| Ten of Spade | 9 |
| Ten of Heart | 35 |
| Jack of Spade | 10 |
| Jack of Heart | 36 |
| Queen of Spade | 11 |
| Queen of Heart | 37 |
| King of Spade | 12 |
| King of Heart | 38 |
| Ace of Spade | 13 |
| Ace of Heart | 39 |
| Two of Club | 14 |
| Two of Diamond | 40 |
| Three of Club | 15 |
| Three of Diamond | 41 |
| Four of Club | 16 |
| Four of Diamond | 42 |
| Five of Club | 17 |
| Five of Diamond | 43 |
| Six of Club | 18 |
| Six of Diamond | 44 |
| Seven of Club | 19 |
| Seven of Diamond | 45 |
| Eight of Club | 20 |
| Eight of Diamond | 46 |
| Nine of Club | 21 |
| Nine of Diamond | 47 |
| Ten of Club | 22 |
| Ten of Diamond | 48 |
| Jack of Club | 23 |
| Jack of Diamond | 49 |
| Queen of Club | 24 |
| Queen of Diamond | 50 |
| King of Club | 25 |
| King of Diamond | 51 |
| Ace of Club | 26 |
| Ace of Diamond | 52 |
Instructions
Rules, Tips and Instructions
- The competition is open to all (national as well as international students, researchers and professionals).
- The codes should be in follwing languages only :
- C
- C++
- Java
- Pearl
- Ruby
- Python
- The decision of the organising team shall be regarded as final in case of any discrepancy.
- A single file has to be submitted containing the source code. Text files will be created only during the game play.
- Text files are an aid to the teams as they can guess the tactics of their opponents by judging their moves, exactly what we do while playing any card game.
- The maximum number of text files a team can make is 15.
- Time the code of a particular team takes to compute should be realistic, preferably less than 1 second. Codes taking a lot of time will be disqualified.
- Small blind and Big blind are fixed to 5 and 10 units respectively. These will be added in the file by the admin before the beginning of the deal. The initial amount given to each team is equal to 1500 units.
- On a whole, there will be 1000 deals on a single table. Say, deal 1 is goin on. Teams have to decode the information from deal.txt during deal 1 in their help files. When deal 2 starts, initial deal file having statistics of deal 1 is lost and during deal 2, teams have to rectify the information in their help files using the statistics of deal 2. So, teams have to continously improve the information in their help files during the successive deals.
- No actual money is involved in the game. Prize money will be finally given to the winner and is independent of the virtual money involved in the game.
- Teams including bluff and other clever programming will surely have an upper edge over others.
- To quickly check whther a card is a high card or not, the integral representation of the card when modulo 13 will give a high value. To check whether two cards are of same suit, the quotient on dividing by 13 is same.
- Note that at any point of time the latest information will be that which is on the site. The information provided in the pdf downloaded earlier may not be the latest. However, registered participants will be informed through mail about any changes on the site.
Certificate Policy
Top 6 teams will be given the Certificate of Excellence. Teams whose codes will run withour errors for the entire course of the game will be given the Certificate of Participation.Team Specifications
The participating entries must be in a team of maximum of 3 [three] people. If the participating team feels that they require more participants, they can forward their request, with suitable reasons, to codempoker[at]techfest[dot]org with the subject "Code'em Poker team number increase".Rules of Poker
Type
The game we will be playing is No Limit Texas Hold'em Poker.Quick Glossary
- Blinds: Short for "blind bets," these are the forced bets made before the cards are dealt.
- Burn Card: The card dealt facedown before any community card is dealt.
- Button: Nickname for the player acting as the dealer in current hand.
- Check: Similar to a call, but no money is bet. If there is no raise preflop, the big blind may check.
- Fifth Street: or River.
- Hole Cards: The two cards given to each player before the flop.
- Flop: The first three community cards dealt.
- Fourth Street: or Turn.
- Preflop: Anything that occurs before the flop is dealt is preflop.
- River: The final (5th) community card dealt; also known as fifth street.
- Showdown: When players reveal their hands to discover the pot's winner.
- Turn: The fourth community card dealt; also known as fourth street.
Setup
The first thing is picking the player who will start with the dealer button. The game will be played with what's known as a rotating dealer, meaning a player will act as the dealer for one hand, handing the role of dealer to the player on their left when the hand is completed. The dealer for the first hand will be chosen at random or by number of victories in previous games (chosen by admin).Putting Out the Blinds
Now that we have a dealer, we need to put out the blinds. There are two blinds - a small blind and a big blind. The player directly to the left of the dealer puts out the small blind. The big blind (exactly, or conveniently close to, double that of the small blind) is placed by the player to the left of the small blind. The size of the blinds will dictate the stakes of the game we're about to play.Note : In our game, we have small blind as 5 units and big blind as 10 units and each player is given a total money of 1500 units in the play.
Game Play and Betting Rounds
The person dealing the cards deals to the left of the player with the dealer button first, rotating around the table in a clockwise manner, giving each player one card at a time until each player has two cards. These cards are called hole cards. A hand or round consists of a minimum of one and a maximum of four betting rounds. A hand ends when all players but one have folded, or the fourth and final betting round completes with multiple players still in the hand - whichever comes first. At that point, players enter into the showdown (to be explained in the next section).Pre Flop
When all players receive their hole cards, we are now in the preflop betting round. Each player must look at their cards and decide what action they would like to take. Only one player can act at a time. The preflop betting round starts with the player to the left of the big blind. This player has three options:- Fold: They pay nothing to the pot and throw away their hand, waiting for the next deal to play again.
- Call: They match the amount of the big blind.
- Raise: They raise the bet by doubling the amount of the big blind.
Once a player has made their action, the player to the left of them gets their turn to act. Each player is given the same options: fold, call the bet of the player to their right (if the previous player raised, that is the amount you must call) or raise. A raise is always the amount of one bet in addition to the amount of the previous bet, for example: if the big blind is 25¢, and the first player to act would like to raise, they put in a total of 50¢ (the big blind + one additional bet). If the next player would like to reraise, they would put in a total of 75¢ (the previous bet + one additional bet).
A betting round ends when two conditions are met:
- All players have had a chance to act.
- All players who haven't folded have bet the same amount of money for the round.
Example Betting Round 1
There are five players at the table:
Player 1 - Button
Player 2 - Small blind (10¢)
Player 3 - Big blind (25¢)
Start of betting round
Player 4 - Calls the big blind (25¢)
Player 5 - folds
Player 1 - Calls the big blind (25¢)
Player 2 - Calls the big blind (since they already have 10¢ bet, they only have to add another 15¢, for a total of 25¢)
Player 3 - Checks (since they already have the bet matched, they do not need to add more money to call; this is called checking)
End of betting round
When Player 2 calls the big blind, all players now have the same amount of money in front of them, but Player 3 (the big blind) has not had a chance to act, so the betting round is not over. Once Player 3 checks, both conditions are met, and the betting round is over.
Example Betting Round 2
There are five players at the table:
Player 1 - Button
Player 2 - Small blind (10¢)
Player 3 - Big blind (25¢)
Start of betting round
Player 4 - Calls the big blind (25¢)
Player 5 - Raises (50¢)
Player 1 - Folds
Player 2 - Folds
Player 3 - Reraises (they already have 25¢ in as the big blind. They complete the bet of 50¢, and add one additional bet for a total of 75¢)
Player 4 - Folds (their previous call of 25¢ is now in the pot)
Player 5 - Calls (matches the bet of Player 3 for a total of 75¢)
End of betting round
In this scenario all players had had a chance to act when Player 3 made the reraise. But all players did not have the same amount of money bet. Once Player 4 folds, only Player 3 and Player 5 are left in the pot. When Player 5 calls, both conditions are met, and the betting round ends.
The Flop
Once the preflop betting round ends, the flop is dealt. This is done by dealing the top card in the deck facedown on the table (it becomes the burn card), followed by three cards faceup. Once this has been dealt, the first post-flop betting round begins. The rules of a post-flop betting round are the same as a preflop, with two small exceptions: The first player to act is the next player with a hand to the left of the dealer, and the first player to act can check or bet; as there has been no bet made, calling is free. A bet on the flop is the amount of the big blind initially. After this, a raise is always by the amount atleast of the previous raise (say, for example, small blind is 5 units and big blind is 10 units, and among six players player 3 is dealer, player 2 is small blind and player 1 is big blind. Now, say player 6 raises by 30 to raise to 40 units. Now, if player 5 has to raise, he has to raise by a minimum of 30 i.e. he has to bet atleast 70 if he wants to raise otherwise he has to call. This rule applies for every betting round, whether pre-flop, flop, turn or river. At the start of each round, the minimum raise is of big blind only).The Turn
Once the betting round on the flop completes, the dealer deals one card facedown followed by a single card faceup, also known as the "burn and turn." Once the turn has been dealt, the third betting round starts. The third betting round is identical to the flop betting round with one single exception: The size of a bet for this round, and the final betting round, is doubled, meaning that to make a bet in our game will now cost a player twice of the big blind.The River
Assuming more than one player is left, having not folded on one of the previous streets, the river is now dealt. Dealing the river is identical as dealing the turn, with one card being dealt facedown, followed by a single card faceup. This is the final street, and no more cards will be dealt in this hand. The betting round is identical to the betting round on the turn.Show Down
Once the river betting round has been completed, the players now enter into the showdown. At this point, the best hand wins the pot. Best hand is the best five cards among the 7 (2 hole and 5 cards on the deck). Order of rankings is :- Royal Flush: A straight from a ten to an ace with all five cards of the same suit. In poker all suits are ranked equally.
- Straight Flush: Any straight with all five cards of the same suit.
- Four of a Kind: Any four cards of the same rank. If two players share the same Four of a Kind, the bigger fifth card (known as the kicker) decides who wins the pot.
- Full House: Any three cards of the same rank together with any two cards of the same rank.
- Flush: Any five cards of the same suit (not consecutive). The highest card of the five determines the rank of the flush. Ace-high flush is the highest possible.
- Straight: Any five consecutive cards of different suits. Aces can count as either a high or a low card. For example, Ace, Two, Three, Four and Five of different suits : a five-high straight, which is the lowest possible straight.
- Three of a Kind: Any three cards of the same rank. Fur example three-of-a-kind Aces, with a King and a Queen as side cards - the best possible three of a kind.
- Two Pair: Any two cards of the same rank together with another two cards of the same rank. Fur example the best possible two-pair, Aces and Kings. The highest pair of the two determines the rank of the two-pair.
- One Pair: Any two cards of the same rank. The best possible one-pair hand is two Aces.
- High Card: Any hand not in the above-mentioned hands. The best possible high-card hand is Ace.
No Limit Texas Holdem Poker
In No-Limit a minimum raise is equal to the size of the big blind or the previous raise while a maximum bet is the total amount of all of your chips.If at some point of time, a team has insufficient money to call, it can put all his money and still continue in the game. In such a case the main pot will be having the money equal to the bet by the player who has done all in and the rest will be collected in a side pot. If the player who has done all in wins the final hand, he is liable to get only the main pot and the side pot will be given to the winner among other players.
Timeline
The timeline of the competition is changed. Due to minimal reaction from participants in terms of submission of their codes, we will be providing the participants with a sample code and a sample admin program by 12th December, 2011. The participants have to analyse the samples and then modify their codes to rectify the errors they have done in their codes. Then the participants have to submit the final codes by 30th December, 2011 to codempoker@techfest.org. These will be regarded as final.
Now, atleast one member from each team should be present at the time of simulation of the team's code during the festival i.e. 6th to 8th January, 2012. For international participants, it is not necessary though preferred. Also, if some national team is unable to come, they have to explain their reason and send a mail to poker[at]techfest[dot]org with the subject "Poker arrival pains".
All the enteries obtained will be grouped in teams of six and matches will be played amongst them. Care will be taken to ensure that every team plays with every other team though it is subjectibe to change as per time limitations. After a series of matches, top 6 teams will be shortlisted. Now, the competition goes as follows :
Each of the 6 teams will be revealed the player number of their opponets in the final game. They will be shown the winning statistics and game play (the text files i.e. deal.txt of all the games played till now) of the rest of the teams. It will be a single folder have many subfolders, each subfolder corresseponding to every oppenent. A single subfolder will have many sub-subfolders, each sub-subfolder representing one game(table) of the particular opponent. This will contain a text file named number.txt which will have a single entry representing the player number of the particular opponent in that game and then all the 1000 deal files of that game in the same format as were available during game play. Now using all this data, teams have to analyse their opponents strategies so far and they are liable to put this information in their help files or even their codes. If for some reason, after changes, the codes do not work, initial codes will be considered. Also, it is only for the final table that help text files can be made before the game play. (The maximum limit is still 15).
Teams can make programs for analysing the above text files as well. Teams will be given three hours for doing this.
This game will finally be displayed on a graphical Poker inteface.

Techfest Office,
Students' Gymkhana,
IIT Bombay,
Powai, Mumbai-400076
Ph: +91 22 2576 4045
Fax: +91 22 2572 3480
Team Techfest 2011-12. Site best viewed in latest versions of