13:- use_module(library(mcintyre)). 14
15:- if(current_predicate(use_rendering/1)). 16:- use_rendering(c3). 17:- endif. 18:- mc. 19:- begin_lpad. 20
21n(N): uniform(N,[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).
22color(X,C):uniform(C,[grey, blue, black]):-material(X, metal).
23color(X,C):uniform(C,[black, brown]) :- material(X,wood).
24material(X,M):finite(M,[wood:0.3,metal:0.7]) :- n(N), between(1, N, X).
25drawn(_,B) : uniform(B,L):-n(N), findall(X, between(1, N, X), L).
26size(X,S):beta(S,2, 3) :- material(X,metal).
27size(X,S):beta(S,4, 2):-material(X,wood).
28
29
30
31:- end_lpad.
?-
mc_sample(drawn(1,1),1000,T,F,P)
. %T = 285, %F = 715, %P = 0.285.?-
mc_sample(drawn(1,1),1000,T,F,P)
. %T = 290, %F = 710, %P = 0.29.?-
mc_sample(drawn(1,1),1000,T,F,P)
. %T = 283, %F = 717, %P = 0.283.?-
mc_sample((drawn(1,1),material(1,wood)),1000,T,F,P)
. %T = 86, %F = 914, %P = 0.086.?-
mc_sample((drawn(1,1),material(1,wood),color(1,black)),1000,T,F,P)
. %T = 44, %F = 956, %P = 0.044.*/