Basketball Simulation
- 1. largen = 50;
kuscore = 0;
wiscore = 0;
For[i = 1, i <= largen, i = i + 1,
u = Random[Real, 1];
If[u < .56, poss = 1];
If[(u >= .56) && (u < .83), poss = 2];
If[u >= .83, poss = 3];
If[(poss == 1), u2pt = Random[Real, 1]];
If[(poss == 1) && (u2pt <= .529), wiscore = wiscore + 2];
If[(poss == 1) && (u2pt > .529), poss = 4];
If[poss == 2, u3pt = Random[Real, 1]];
If[(poss == 2) && (u3pt <= .358), wiscore = wiscore + 3];
If[(poss == 2) && (u3pt > .358), poss = 4];
If[(poss == 4), urbd = Random[Real, 1]];
If[(poss == 4) && (urbd <= .218), urbd = z];
z = Random[Real, 1];
If[z < .56, poss = 1];
If[(z >= .56) && (z < .83), poss = 2];
If[z >= .83, poss = 3];
If[(poss == 1), u2pt = Random[Real, 1]];
If[(poss == 1) && (u2pt <= .529), wiscore = wiscore + 2];
If[poss == 2, u3pt = Random[Real, 1]];
If[(poss == 2) && (u3pt <= .358), wiscore = wiscore + 3];
v = Random[Real, 1];
If[v < .63, poss = 1];
If[(v >= .63) && (v <.87 ), poss = 2];
If[v >= .87, poss = 3];
If[(poss == 1), v2pt = Random[Real, 1]];
If[(poss == 1) && (v2pt <= .51), kuscore = kuscore + 2];
If[(poss == 1) && (v2pt > .51), poss = 4];
If[(poss == 2), v3pt = Random[Real, 1]];
If[(poss == 2) && (v3pt <= .38), kuscore = kuscore + 3];
If[(poss == 2) && (v3pt > .38), poss = 4];
- 2. If[(poss == 4), vrbd = Random[Real, 1]];
If[(poss == 4) && (vrbd <= .211), vrbd = y];
y = Random[Real, 1];
If[y < .63, poss = 1];
If[(y >= .63) && (v < .87), poss = 2];
If[y >= .87, poss = 3];
If[(poss == 1), v2pt = Random[Real, 1]];
If[(poss == 1) && (v2pt <= .51), kuscore = kuscore + 2];
If[(poss == 2), v3pt = Random[Real, 1]];
If[(poss == 2) && (v3pt <= .38), kuscore = kuscore + 3];
] ;
Print["Final wiscore is: ", wiscore];
Print["Final kuscore is: ", kuscore];
largen = 31;
wiftscore = 0;
For[i = 1, i <= largen, i = i + 1, u = Random[Real, 1];
If[u <= 1, poss = 1];
If[(poss == 1), u1pt = Random[Real, 1]];
If[(poss == 1) && (u1pt <= .71), wiftscore = wiftscore + 1];]
Print["Final wiftscore is: ", wiftscore];
largen = 21;
kuftscore = 0;
For[i = 1, i <= largen, i = i + 1, v = Random[Real, 1];
If[v <= 1, poss = 1];
If[(poss == 1), v1pt = Random[Real, 1]];
If[(poss == 1) && (v1pt <= .80), kuftscore = kuftscore + 1];]
Print["Final kuftscore is: ", kuftscore];