smg
player investor [invest], [noinvest], [cashin], [done] endplayer
player env [bar], [nobar], [month] endplayer
module sched
m : [0..2];
[noinvest] (m=0) -> (m'=1);
[invest] (m=0) -> (m'=1);
[bar] m=1 -> (m'=2);
[nobar] m=1 -> (m'=2);
[month] m=2 -> (m'=0);
[cashin] m=0 -> (m'=0);
[done] m=0 -> (m'=0);
endmodule
module investor
i : [0..2];
[noinvest] (i=0 | i=1 & b=1) -> (i'=0);
[invest] (i=0 | i=1 & b=1) -> (i'=1);
[cashin] i=1 & b=0 -> (i'=2);
[done] (i=2) -> true;
endmodule
module barred
b : [0..1] init 1;
[nobar] true -> (b'=0);
[bar] b=0 -> (b'=1);
endmodule
const vmax;
const vinit;
module value
v : [0..vmax] init vinit;
[month] true -> p/10 : (v'=min(v+1,c,vmax)) + (1-p/10) : (v'=min(max(v-1,0),c));
endmodule
const int pmax = 10;
module probability
p : [0..pmax] init floor(pmax/2);
[month] (v<5) -> 2/3 : (p'=min(p+1,pmax)) + 1/3 : (p'=max(p-1,0));
[month] (v=5) -> 1/2 : (p'=min(p+1,pmax)) + 1/2 : (p'=max(p-1,0));
[month] (v>5) -> 1/3 : (p'=min(p+1,pmax)) + 2/3 : (p'=max(p-1,0));
endmodule
const int cmax = vmax;
module cap
c : [0..cmax] init cmax;
[month] true -> 1/2 : (c'=max(c-1,0)) + 1/2 : (c'=c);
endmodule
label "finished" = i=2;
rewards "profit"
[cashin] i=1 : v;
endrewards
rewards "penalties"
[invest] true: 1;
[noinvest] true: 1;
endrewards