/* Tornado poker in Picat. From Julian Simon """ You are standing in the warehouse of a playing-card factory that has been hit by a tornado. Cards are scattered everywhere, some not yet wrapped and others ripped out of their packages. The factory makes a variety of decks - for poker without a joker, poker with a joker, and pinochle; magician's decks; decks made of paper and others of plastic; cards of various sizes; and so on. Two hours from now a friend will join you for a game of near-poker with these cards. Each hand will be chosen as randomly as possible from the huge heap of cards, and then burned. What odds should you attach to getting the combination two-of-a-kind - two cards of different or the same suit but of the same number or picture - in a five-card draw? """ Cf my Gamble model gamble_tornado_poker.rkt This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import ppl_distributions, ppl_utils. import util. % import ordset. main => go. /* * Exactly one pair (i.e. no three-of-a-kind, no two pairs, not full hand etc). var : p1 Probabilities: false: 0.5274000000000000 true: 0.4726000000000000 mean = [false = 0.5274,true = 0.4726] * At least one pair, i.e. including three-of-a-kind etc var : p2 Probabilities: true: 0.5875000000000000 false: 0.4125000000000000 mean = [true = 0.5875,false = 0.4125] */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean % , % show_percentiles,show_histogram, % show_hpd_intervals,hpd_intervals=[0.94], % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => Cards = rep(4,1..13).flatten, % Pick 5 cards Pick5 = resample(5,Cards), % note: with replacement % Count the occurrences of the cards H = Pick5.get_freq().values, % Exactly one pair P1 = check(H.len == 4), % At least one pair P2 = check(H.len < 5), add("p1",P1), add("p2",P2).