.. index:: Poker Example

.. _Poker_Example:

A simplified poker game
=======================

This example originates from the textbook :ref:`Bayesian Networks and Decision Graphs<references>`.

Consider a simplified poker game with the following rules:

Each player receives three cards and is allowed two rounds of changing cards. In the first round you may discard any number of cards from your hand and get replacements from the pack of cards. In the second round you may discard at most two cards.

The various types of hands are classified in the following way (in increasing rank): nothing special, 1 ace, 2 of the same value, 2 aces, flush (3 of a suit), straight (3 of consecutive values), 3 of the same value, straight flush.

The following Bayesian network can compute the probability of you having the best hand after the two ronds of changing, based on the number of cards your opponent has discarded and an assumed strategy of the opponent:

.. figure:: images/poker.png

The nodes OH0, OH1 and OH2 represent the opponents hand initially, after the first change (FC) and after the second change (SC) respectively. MH represents my hand before the bidding starts. Note that we have exact knowledge of the state of this node, so the initial distribution is not important.

Of course the probabilities of the various states of OH2 depend on the presumed strategy of the opponent.

In the network enclosed in the installations of HUGIN, the following strategy for the opponent is assumed:

* If nothing special, then change 3.
* If 1 ace, then keep the ace.
* If 2 of consecutive values or 2 of a suit or 2 of the same value, then discard the third card.
* If 2 of a suit and 2 of consecutive values, then keep 2 of a suit.
* If 2 of a suit and 2 of the same value or 2 of consecutive values and 2 of the same value, then keep the 2 of the same value.
* If flush, straight, 3 of the same value or straight flush, then keep it.

Now you can enter the states of FC, SC and MH and get the probability of you having the best hand.

This network has been installed on your computer with the HUGIN software. Open the network in the HUGIN Graphical User Interface (Note: not all browsers can open HUGIN directly). You can find the network in the directory where you installed HUGIN (e.g. C:\Program Files\Hugin\Hugin Lite\Samples).
You can also find the samples at the `HUGIN download area <http://download.hugin.com/samples>`_.