/* Schelling coordination game in Picat. This is a port of the Church ForestDB model, http://forestdb.org/models/schelling.html Here we also study different priors for selecting the good bar (over the bad bar). Cf my Gamble model gamble_schelling_coordination_game.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. /* Using different priors for the good bar and different recursion depths. prior = 0.6 [p = 0.6,depth = 1] var : location Probabilities: good_bar: 0.7753232758620690 bad_bar: 0.2246767241379310 Variable lengths: location = 11136 [p = 0.6,depth = 2] var : location Probabilities: good_bar: 0.8851556045166621 bad_bar: 0.1148443954833379 Variable lengths: location = 3631 [p = 0.6,depth = 3] var : location Probabilities: good_bar: 0.9349736379613357 bad_bar: 0.0650263620386643 Variable lengths: location = 1138 [p = 0.6,depth = 4] var : location Probabilities: good_bar: 0.9872773536895675 bad_bar: 0.0127226463104326 Variable lengths: location = 393 [p = 0.6,depth = 5] var : location Probabilities: good_bar: 0.9907407407407407 bad_bar: 0.0092592592592593 Variable lengths: location = 108 [p = 0.6,depth = 6] var : location Probabilities: good_bar: 1.0000000000000000 Variable lengths: location = 62 prior = 0.51 [p = 0.51,depth = 1] var : location Probabilities: good_bar: 0.5296926290659505 bad_bar: 0.4703073709340496 Variable lengths: location = 10053 [p = 0.51,depth = 2] var : location Probabilities: good_bar: 0.5502218636546995 bad_bar: 0.4497781363453005 Variable lengths: location = 2479 [p = 0.51,depth = 3] var : location Probabilities: good_bar: 0.5915492957746479 bad_bar: 0.4084507042253521 Variable lengths: location = 639 [p = 0.51,depth = 4] var : location Probabilities: good_bar: 0.6047904191616766 bad_bar: 0.3952095808383234 Variable lengths: location = 167 [p = 0.51,depth = 5] var : location Probabilities: good_bar: 0.7647058823529411 bad_bar: 0.2352941176470588 Variable lengths: location = 34 [p = 0.51,depth = 6] var : location Probabilities: good_bar: 0.8000000000000000 bad_bar: 0.2000000000000000 Variable lengths: location = 5 prior = 0.5 [p = 0.5,depth = 1] var : location Probabilities: good_bar: 0.5043107820265748 bad_bar: 0.4956892179734253 Variable lengths: location = 9859 [p = 0.5,depth = 2] var : location Probabilities: bad_bar: 0.5001964636542240 good_bar: 0.4998035363457760 Variable lengths: location = 2545 [p = 0.5,depth = 3] var : location Probabilities: good_bar: 0.5253968253968254 bad_bar: 0.4746031746031746 Variable lengths: location = 630 [p = 0.5,depth = 4] var : location Probabilities: bad_bar: 0.5472972972972973 good_bar: 0.4527027027027027 Variable lengths: location = 148 [p = 0.5,depth = 5] var : location Probabilities: good_bar: 0.5581395348837209 bad_bar: 0.4418604651162791 Variable lengths: location = 43 [p = 0.5,depth = 6] var : location Probabilities: bad_bar: 0.6250000000000000 good_bar: 0.3750000000000000 Variable lengths: location = 8 prior = 0.4 [p = 0.4,depth = 1] var : location Probabilities: bad_bar: 0.7705035971223022 good_bar: 0.2294964028776978 Variable lengths: location = 11120 [p = 0.4,depth = 2] var : location Probabilities: bad_bar: 0.8818000569638280 good_bar: 0.1181999430361720 Variable lengths: location = 3511 [p = 0.4,depth = 3] var : location Probabilities: bad_bar: 0.9486963835155593 good_bar: 0.0513036164844407 Variable lengths: location = 1189 [p = 0.4,depth = 4] var : location Probabilities: bad_bar: 0.9913978494623656 good_bar: 0.0086021505376344 Variable lengths: location = 465 [p = 0.4,depth = 5] var : location Probabilities: bad_bar: 0.9815950920245399 good_bar: 0.0184049079754601 Variable lengths: location = 163 [p = 0.4,depth = 6] var : location Probabilities: bad_bar: 0.9818181818181818 good_bar: 0.0181818181818182 Variable lengths: location = 55 */ go ?=> member(P,[0.6,0.51,0.5,0.4]), println(prior=P), member(Depth,1..6), println([p=P,depth=Depth]), reset_store, run_model(40_000,$model(P,Depth),[show_probs]), % [show_probs,min_accepted_samples=1000]), nl, show_store_lengths,nl, fail, nl. go => true. % This was the original problem, i.e. prior of 0.6 % sample_location() = cond(flip(0.6) == true,good_bar,bad_bar). % Let's generalize this for various priors of good bar sample_location(P) = cond(flip(P) == true, good_bar, bad_bar). % Alice think about what Bob think about what Alice think what Bob think... alice(Depth,P) = Res => AliceLocation = sample_location(P), observe(AliceLocation == bob(Depth-1,P)), Res = AliceLocation. % Bob think about what Alice think what Bob think... bob(Depth,P) = Res => BobLocation = sample_location(P), if Depth == 0 then observe(true) else observe(BobLocation == alice(Depth,P)) end, Res = BobLocation. model(P,Depth) => Location = bob(Depth,P), if observed_ok then add("location",Location) end.