/* Craps in Picat. https://en.wikipedia.org/wiki/Craps """ Craps is a dice game in which players bet on the outcomes of a pair of dice. Players can wager money against each other (playing "street craps") or against a bank ("casino craps"). ... If the come-out roll is 7 or 11, the bet wins. If the come-out roll is 2, 3 or 12, the bet loses (known as "crapping out"). """ Cf my Gamble model gamble_craps.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. /* var : d1 Probabilities: 2: 0.1705000000000000 1: 0.1695000000000000 6: 0.1667000000000000 3: 0.1653000000000000 4: 0.1650000000000000 5: 0.1630000000000000 mean = 3.4816 var : d2 Probabilities: 6: 0.1720000000000000 3: 0.1715000000000000 4: 0.1709000000000000 5: 0.1662000000000000 1: 0.1611000000000000 2: 0.1583000000000000 mean = 3.5388 var : bet wins Probabilities: false: 0.7745000000000000 true: 0.2255000000000000 mean = 0.2255 var : bet loses Probabilities: false: 0.8903000000000000 true: 0.1097000000000000 mean = 0.1097 var : ńeither Probabilities: true: 0.6647999999999999 false: 0.3352000000000000 mean = 0.6648 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean % , % show_simple_stats % , % show_percentiles, % show_hpd_intervals,hpd_intervals=[0.84,0.9,0.94,0.99,0.99999], % show_histogram, % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => [D1,D2] = dice_n(2), S = D1 + D2, BetWins = check( (S == 7 ; S==11)), BetLoses = check( (S == 2 ; S==3 ; S == 12)), Neither = check( (BetWins == false, BetLoses == false)), add("d1",D1), add("d2",D2), add("bet wins",BetWins), add("bet loses",BetLoses), add("ńeither",Neither).