paloma blog

NWエンジニアやってます。主に自宅環境のお遊びを書きます。Pythonもちょっと。タイトルは好きなカクテルから。

スリーカードポーカーで勝つことはできるのか フォールド処理組み込み編

前回降りる手札判定が出来たところでシミュレータに組み込みます。

シミュレータの流れは

  1. チップベット ($1000スタート、アンティ・ペアプラスは$10固定)
  2. カード配布
  3. 手札判定
  4. 勝負
  5. 払い戻し

となっていますがフォールドの手順をこう組み込みます。

  1. チップベット ($1000スタート、アンティ・ペアプラスは$10固定)
  2. カード配布
  3. 手札判定
    1. フォールドする手札か判定
    2. フォールドならチップ分を引いて終了
  4. 勝負
  5. 払い戻し

こうみるとシンプルで簡単すぎますね。
はやくやっときゃよかった。

手札チェック

Booleanを返すように前回より少し変更してます。

def Foldcheck(hand):
    if pokerapp.Handcheck(hand).result()[0][0] == 1:
        fhand = pokerapp.Handcheck(hand).result()[1]

        if fhand[2] <= 12 and fhand[1] <= 6 and fhand[0] <= 4:
            return True

        else:
            return False
    else:
        return False

引数に手札を与えると、降りる手札の場合Trueを返します。
Trueなら以降の処理は行わずに終了し、賭けたチップを放棄します。

>>> Foldcheck(player)
False
>>> Foldcheck(player)
True

動かしてみる

組み込んだところで動かしてみます。

masashi@PC-ubuntu:~/Three-card-poker$ python3 simulater.py 
You are first given $1,000.
Three card poker simulator start.
The simulator trials 1,000 times.
You'll bet ante $10 and pair plus $10 all the time.
You fold the game if you hand less than Q,6,4 High card.

You could play the game 1000 times.

=== Probabliry of winning or losing ===

Player 500 wins. (50.0%)
Dealer 333 wins. (33.3%)
Draw 0 times. (0.0%)
Fold 167 times. (16.7%)

=== Percentage of Players all hands ===

High card!            58.0%
One Pair!             16.4%
Flash!                 5.7%
Straight!              2.7%
Three of a kind!       0.3%
Straight Flash!        0.2%

=== Percentage of Players win(500 times) hands ===

High card!            56.0%
One Pair!             27.0%
Flash!                10.8%
Straight!              5.2%
Three of a kind!       0.6%
Straight Flash!        0.4%

You finally got $230

弱い手札は降りるようにしたところで結果はあまり変わりませんね。
こう見ると意外とフォールド率が高いです。

目的は勝ち越せるかなので数回回してみましょう。

masashi@PC-ubuntu:~/Three-card-poker$ for a in {1..10} ; do python3 simulater.py | tail -n1 ; done
You finally got $10
You finally got $10
You finally got $20
You finally got $20
You finally got $3,330
You finally got $1,500
You finally got $20
You finally got $1,760
You finally got $10
You finally got $20

1000 × 10回試行して終了時の平均$670ですね。
$1000スタートなので負け越しです…。

結論 やはりうまい話はない

勝ち越せるケースはあるので短期で勝つことは出来ますが長期的にやり続けると負けてしまいますね。
スリーカードポーカーもシンプルながらも良くできています。

シミュレータのお陰でリアルのチップを無駄遣いせずにすみましたw

じゃあ逆に短期決戦で損益の分岐を見極めれば勝ち越せる...?
この研究はまた今度ですね。

前編

スリーカードポーカーで勝つことはできるのか 降りる手札判別編 - paloma blog