examples

## Class PokerHandsNaive

• java.lang.Object
• examples.PokerHandsNaive

• ```public class PokerHandsNaive
extends java.lang.Object```
This is an example program to showcase the use of OpenPAS to solve a probabilistic problem. It models and finds the probability of drawing a Poker pair from a deck. There's a matching `PokerHandsCompact` example that shows how to do this in a more compact manner, but this example should be easier to understand at first.

For modelling a draw of N cards from a deck we create assumptions of cards being dealt. We need N assumptions for each card being dealt one after another, e.g. for 5 draws:

spade, club, heart, and diamond, A, K, Q, J, 10-2
e.g.
D1_SA, D1_SK, ..., D1_D3, D1_D2 (52)
...
D5_SA, D5_SK, ..., D5_D3, D5_D2 (52)

5 * 52 = 260 dealing card assumptions

Then we add the following rules:
1) Only one card can be drawn at a time.
2) A card has to drawn each time.
3) A given card only be drawn once.

Then we define 52 propositions for "having been dealt a card" no matter the order.
e.g. SA, SK, ..., D3, D2 (52)

A good analysis can be seen here: https://en.wikipedia.org/wiki/List_of_poker_hands We only analyse a pair here: having any card with the same rank. There are 13x C(4,2) = 78 different types of pairs.

This is a naive implementation that assigns a new assumption for each draw of a card resulting in an explosion of scenarios. We can only analyse the case for two draws using this model and OpenPAS. This involves 104 assumptions and ~ 2e31 possible scenarios to analyse. OpenPAS manages this in ca. 15 hours on a modest laptop (as of 2017) (see `PokerHandsCompact` for a much faster version and more details about performance).

To get quicker response play with the NUM_DRAWS/NUM_SUITS/NUM_RANKS values below. For example, an assignment of 2/2/2 returns immediate results. Analysing smaller models of problems makes it easier to spot problems.

The idea for this program is that, you run it to generate an .ops file which allows an import into `PASC` using the 'run' command. Then you can do interactive analysis. The 'scenarios' command is a useful command to analyse how your PAS model works.

When run, this program will write a PASC importable PAS instance to disk, and continue to calculate the dsp for "got_pair" which is the proposition for getting a Poker pair.
`PokerHandsCompact} for a different approach to the same problem which actually works for 5 draws.`
• ### Constructor Summary

Constructors
Constructor and Description
`PokerHandsNaive()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static java.lang.String` `getCardName(int index)`
`static java.lang.String` ```getCardName(int s, int rank)```
`static java.lang.String` ```getDrawnCardName(int draw, int index)```
`static java.lang.String` ```getDrawnCardName(int draw, int s, int rank)```
`static void` `main(java.lang.String[] args)`
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### PokerHandsNaive

`public PokerHandsNaive()`
• ### Method Detail

• #### getCardName

```public static java.lang.String getCardName(int s,
int rank)```
• #### getCardName

`public static java.lang.String getCardName(int index)`
• #### getDrawnCardName

```public static java.lang.String getDrawnCardName(int draw,
int s,
int rank)```
• #### getDrawnCardName

```public static java.lang.String getDrawnCardName(int draw,
int index)```
• #### main

```public static void main(java.lang.String[] args)
throws PAS.KBException,
java.io.FileNotFoundException```
Throws:
`PAS.KBException`
`java.io.FileNotFoundException`