Shop OBEX P1 Docs P2 Docs Learn Events
Can COGs play poker with each other, or with us? — Parallax Forums

Can COGs play poker with each other, or with us?

cessnapilotcessnapilot Posts: 182
edited 2009-08-17 20:13 in Propeller 1
Hi All,

The answer is: Yes they can, but not in Texas Hold'em. Until KISS OS arrives in a large black box, we can make some smaller scale AI experiments in bluffing with a simpler poker game using an open minded (source) Propeller, and that will be fun.

Poker combines three timeless elements of fun:
1. Luck
2. Skill
3. Politics (bluff)

When we play this game of chance, logic and lies again and again, only the rules remain the same. We have fun with feeling of adventure while competing against the fate, and if we are wise enough to learn, we may figure out how we grab hold of·chance through our own efforts. Fun is essential in our life, like vitamins for the body. Chuck Yeager said it is important to have fun once a day, or more.

Texas Hold'em (TH) is a 7-card poker game it played with a full deck of 52 cards, where each player (typically ten at a table) is dealt two hole cards that are private, these cards will not be revealed until showdown, and then shares five public cards, which are presented in three stages. The first stage is called the Flop and consists of three cards. The next two stages each consisting of one card are the Turn and the River. There are four betting rounds, starting with pre-Flop and each stage is followed by one. After the fourth betting round comes the showdown if necessary.

TH is farmore complicated for todays computers and mathematics to understand even its basics, not to mention of producing a program to beat skilled human opponents. Even a two-player, very limited Texas Hold'em requires >10^18 parameters. For us humans, the rules of TH may first seem complicated, but spend some time practicing and this poker game will become second nature. Believe me, this is personal.

Computers, beside all of their incapabilities, can help us to develop our strategies in TH. Look at the three attachments.·The first shows the values of five cards in hand, the second the winning probabilities (%) of the two private cards, where we can make general comments about the strength of hands within these rankings. First, high cards and pairs are more likely to be found near the top of the listings. These hands have a high chance of winning in a showdown without any improvement from the board cards. Secondly, two suited cards are always stronger than the respective offsuit hand due to the increased chances of making a flush. Finally we see that zero-gap hands are generally more highly rated than similar one- and two-gap hands due to their straight potential. The third attachment shows a conservative stationary strategy for the pre-Flop betting, based upon the first matrix. There are miriad of other strategies, including switching or drifting tactics, too, or mixes of them for each stage of the game. The basic aim of these strategies can be described as Win as much as you can, but when you about to lose, lose as little as you can.

While computation mathematics is struggling, although with some nonzero success, with the basic uderstanding of TH game, all strong players decide upon a course of action by incorporating knowledge of their opponents’ previous betting patterns. This is called opponent modeling. Players who are able to use this additional information fare better than those (computers) who base decisions on their hand strength alone.

Mathematicians study many simplified version of poker to begin its understanding. For example, Rhode Island Hold'em (RIH) is a restricted version of TH: it is played with a full deck of 52 cards, but each player receives only a single face-down hole card, and there are only two community cards. There are three rounds of betting, with up to three raises per betting round. The treatment of RIH contains series of matrices with taking about 600MB of memory for each to store. (In some lucky circumstances you can pack 128KB of data into a COG, but 600MB is really too much, especially in many hundred times.)

On that route of simplification Scientists arrived to the bottom with the Jack-Queen-King Toy (JQK) poker (Kuhn), and this game is child's play for a COG. JQK poker is for two players, hereafter known as COG A and COG B. The rules:

Both competitors ante $1, then receive a card from a deck consisting of a Jack, a Queen, and a King. COG A (Alice, Player 1) is first to act, and after looking at her card may either bet $1 or fold. If she folds, COG B (Bob, Player 2) wins the pot. If she bets, Player 2 must then either call for $1 or fold. Should Player 2 fold, Player 1 wins the pot. If Player 2 calls, the winner is determined
by a showdown (King > Queen > Jack).

The two COGs compete in repeated hands, with the deal (COG D?) and thus the seating position of each alternating. Each COG is therefore required to act cyclically as Player 1 and Player 2.

JQK poker has most of the strategic properties found in the real world games of poker, yet a full analysis of the game exists. In JQK poker we bluff by betting with a Jack and trap by passing with a King. In addition, best-response can be calculated.

Good strategies for both players uses probabilities. One of them for example is: Player 1 should always bet the Queen and King, and the Jack only one third of the time. Likewise Player 2 should always fold the Jack, call one third of the time with the Queen, and always call with the King. Many similar, equilibrium strategies exists. If either player plays this or a similar equilibrium strategy then Player 1 will lose 5.5 cents per game on average. Since they change seat after each play, the game is fair. Although the equilibrium strategy, a so called Nesh strategy (Beautiful Mind), guarantees, a minimum payoff no matter the opponent's strategy, better payoffs may still be possible, if the player is smart enough. If player 1 knows or learns Player 2's strategy, instead Nesh responds by passing in the first round and betting with a King or Queen when bet to (i.e., the best response), it is no longer a losing game, with the expected payoff being zero.

As such, equilibrium strategies are 'safe' in the sense that things can't get any worse. As mentioned above, the Nash strategies for Player 1 in JQK poker guarantee a value of -1/18$, and thus guarantee a loss. Against a given P2 strategy, some non-Nash P1 strategy could be better or worse. So, though Nash is a losing proposition for P1, it may be better than the alternatives against an unknown opponent. It therefore makes sense to adopt a Nash strategy until an opponent model can be learned. Then the best means of exploiting that model can be tried.

But, there is a very big problem with JKQ poker! It's boring, unless you are a mathematician. I am not. Alice, a learning and adapting COG, beated me all the time on the long term, and that is especially BORING. One day after a long night of many hands, Alice was found dead in the Recycle Bin.

I miss Alice, so, I am trying now to invent small poker with simple rules, that resembles Texas Hold'em and is much more interesting that the dull JQK poker. I propose here the

····· ································ Prop Hold'em
········· ·························· *************

that·is simpler than the Rhode Island Hold'em, and likely to be programmed into a COG with some AI features.

The proposed rules of Prop Hold'em:
====================================
The deck consists 16 ($10) cards, namely 4 Aces, 4 Kings, 4 Queens and 4 Jacks in 4 different suits.

Maximum number of players is 15 ($F)

All competitors ante $1.

Play begins with each player being dealt one card face down. This is the only card each player will receive individually, and it shall not be revealed until showdown.

A first pre-flop (before a community card is dealt) betting round now takes place, beginning with the player to the left of the dealer. There is one bet per player per round. The first player, after looking at his card may either bet $1 or fold. If he bets, Player 2 must then either call for $1 or fold, and so do the other players, one after another.

If everybody fold before the last player, he wins the pot. If there is only one bet during this betting, the player who bets, wins the pot.

If there is at least one bet and that is followed with one ore more calls, the hand continues.

Next the dealer deals a face-up community card that anyone can then use in their hand· and then this is followed by a second (and last) betting round.

After the second betting round comes the showdown if necessary.

The holder of the best hand, determined by a relative ranking of all possible hands, wins all $s posted into the pot.

············· Ranking of hands in Prop Hold'em

····· Hand·········· No. of occurencies·············Definition
1. Royal Flush··············· 4············· Ace and King of the same suit
2. Straight Flush············ 8············· King and Queen, or Queen and Jack suited.
3. Two of a kind············ 24··········· Two identical faces
4. Flush····················· · 36············ Two suited cards, but with gap between the faces.
5. Straight··············· ··· 48············ Two following faces, but offsuit. Ace considered high or low here
6. High Card··············· 120············· None of the previous.

Ranking of cards in High cards or in alike Hands is Ace > King > Queen > Jack.

The holder of the highest ranked hand wins the pot. The suits are not ranked, so it can happen that the pot is splitted.·For example, a KQ Straight Flush is· stronger than a QJ one, but all Royal Flushes are of equal strength.

I hope that I made not too many mistakes in the calculation of occurencies, so that ranking of hands is correct. If you see some error, please let me know. The probabilities are critical in the ranking of hands, or in the strategies. Ideas for better rules are welcome, too.

The main SPIN program can be the dealer and the supervisor of the fairness of the game. Data and control is passed via specified HUB registers to the COGs and on the screen to the single human player. Player COGs hide their internal status and does not discuss with each other, or with the human. COGs are not allowed to use other part of the HUB memory than the communication registers, specified for them individually, and they are especially not allowed to look into each other's card. Players accept commands like "You are Player 1", "Your card is a Queen", and answer questions like "Bet or Fold?". The brave human player responds via keyboard and COGs post their decisions into those specified HUB registers. The role of Player 1, i.e. the seating position, goes CW· around the active players in the consecutive games.

Betting, folding, calling, bluffing, trapping and showdown are all components of Prop Hold'em. Smarter COGs may use internal random number generators to mix strategies. The probability tables or strategy choices of Prop Hold'em are small, the rules are simple. COGs can be programmed to apply simple or advanced strategies, or even to learn opponent's behavior. The game has not trivial or known solution. This makes Tournaments (with $10 cash at start·with each player, or so) between COGs interesting to find winner algorithms. Those future winner algorithms can be seated in a game program against a self confident human player.

Have Fun!

Cheers,

Istvan
717 x 468 - 67K
867 x 346 - 115K
861 x 339 - 109K

Comments

  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2009-08-17 19:59
    What a cute idea!

    Cogs playing games against each other...if you have a real random number generator of some sort
    like using diode noise or similar that would make it even better.

    Output the whole thing to a fun VGA display and it would make a great propeller demo.

    Or have one cog encrypt text using a randomly generated code and another using a brute force
    attack to decrypt it... a propeller Enigma Cipher Machine and British 'BOMB' decoder demo smile.gif

    (BOMB was a nickname for a mechanical computing device used at Blechly Park in England during WW2 to decode German code...It clicked like a ticking bomb
    ..I'm very interested in encryption that's why I know all this useless trivia)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Some mornings I wake up cranky.....but usually I just let him sleep in -
  • John R.John R. Posts: 1,376
    edited 2009-08-17 20:11
    Don't forget to check out this project:

    http://forums.parallax.com/showthread.php?p=812704

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • LeonLeon Posts: 7,620
    edited 2009-08-17 20:13
    One of the early chess-playing programs could play itself.

    Some of the on-line poker games use the Quantis quantum RNG.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
Sign In or Register to comment.