mathematica用
oddslist = Table[Table[0, 10000], 250]; counter =
Table[Table[0, 1001], 250]; For[game = 1, game <= 250, game++,
totalodds = 0; maxodds = 0;
For[times = 1, times <= 100, times++, oddsupinitial = 0;
rowodds = {1.5, 0.6, 0.5, 0.5, 0.6, 1.5};
basicrowodds = {1.5, 0.6, 0.5, 0.5, 0.6, 1.5}; maxchain = 1;
chain = 1; oddsup1 = RandomInteger[{2, 5}];
oddsup2 = RandomInteger[{1, 2}];
Which[oddsup2 == 1, oddsup2 = 1, oddsup2 == 2, oddsup2 = 6];
pattern = allpattern[[game]];
in = {1, 2, 3, 4, 5, 6, 7, 8};
pattern[[RandomInteger[{31, 54}]]] = 6;
random = RandomInteger[{1, 10}];
If[random == 1, pattern[[RandomInteger[{31, 54}]]] = 6];
syokipattern = pattern;
numlist = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
For[i = 1, i <= 100, i++, randomA = RandomInteger[{1, 54}];
randomB = RandomInteger[{1, 54}];
taihi = numlist[[randomA]];
numlist[[randomA]] = numlist[[randomB]];
numlist[[randomB]] = taihi];
syokinumlist = numlist;
For[a = 1, a <= 5, a++, chain = 1; bomblist = Table[0, 54];
erase = Table[0, 54]; k1 = k2 = k3 = k4 = k5 = k6 = 0;
bombwait1 = {0, 0, 0, 0, 0, 0, 0, 0, 0};
bombwait2 = {0, 0, 0, 0, 0, 0, 0, 0, 0};
bombwait3 = {0, 0, 0, 0, 0, 0, 0, 0, 0};
bombwait4 = {0, 0, 0, 0, 0, 0, 0, 0, 0};
bombwait5 = {0, 0, 0, 0, 0, 0, 0, 0, 0};
bombwait6 = {0, 0, 0, 0, 0, 0, 0, 0, 0};
precount = 0; postcount = 1; bombflag = 0;
Which[a == 1,
For[b = 1, b <= 54, b++,
If[numlist[[b]] == in[[1]] || numlist[[b]] == in[[2]] ||
numlist[[b]] == in[[3]],
Which[pattern[[b]] == 6, bombflag = 1; mass = b,
pattern[[b]] < 6, numlist[[b]] = 0; pattern[[b]] = 0]]],
a == 2, For[b = 1, b <= 54, b++,
If[numlist[[b]] == in[[4]] || numlist[[b]] == in[[5]],
Which[pattern[[b]] == 6, bombflag = 1; mass = b,
pattern[[b]] < 6, numlist[[b]] = 0; pattern[[b]] = 0]]],
a == 3, For[b = 1, b <= 54, b++,
If[numlist[[b]] == in[[6]],
Which[pattern[[b]] == 6, bombflag = 1; mass = b,
pattern[[b]] < 6, numlist[[b]] = 0; pattern[[b]] = 0]]],
a == 4, For[b = 1, b <= 54, b++,
If[numlist[[b]] == in[[7]],
Which[pattern[[b]] == 6, bombflag = 1; mass = b,
pattern[[b]] < 6, numlist[[b]] = 0; pattern[[b]] = 0]]],
a == 5, For[b = 1, b <= 54, b++,
If[numlist[[b]] == in[[8]],
Which[pattern[[b]] == 6, bombflag = 1; mass = b,
pattern[[b]] < 6, numlist[[b]] = 0; pattern[[b]] = 0]]]];
If[bombflag == 1, b = mass;
For[e = 1, e <= 1, e++, bomblist[[b]] = 1;
While[precount < postcount,
For[c = 1, c <= 54, c++, precount = postcount;
For[d = 1, d <= Length[nextlist[b]], d++,
If[pattern[[nextlist[b][[d]]]] == 6,
bomblist[[nextlist[b][[d]]]] = 1]];
If[bomblist[[c]] == 1,
For[d = 1, d <= Length[nextlist[c]], d++,
If[pattern[[nextlist[c][[d]]]] == 6,
bomblist[[nextlist[c][[d]]]] = 1]];]];
postcount = Count[bomblist, 1]]; kibaku = Table[0, 54];
For[f = 1, f <= 54, f++,
If[bomblist[[f]] == 1, kibaku[[f]] = 1; pattern[[f]] = 0;
numlist[[f]] = 0;
For[g = 1, g <= Length[nextlist[f]], g++,
tonari = nextlist[f][[g]]; pattern[[tonari]] = 0;
kibaku[[tonari]] = 1]]];
For[f = 1, f <= 54, f++,
If[kibaku[[f]] == 1 && bomblist[[f]] != 1 && numlist[[f]] > 0,
retu = QuotientRemainder[f, 6][[2]]; If[retu == 0, retu = 6];
Which[retu == 1, k1 += 1; bombwait1[[k1]] = numlist[[f]],
retu == 2, k2 += 1; bombwait2[[k2]] = numlist[[f]], retu == 3,
k3 += 1; bombwait3[[k3]] = numlist[[f]], retu == 4, k4 += 1;
bombwait4[[k4]] = numlist[[f]], retu == 5, k5 += 1;
bombwait5[[k5]] = numlist[[f]], retu == 6, k6 += 1;
bombwait6[[k6]] = numlist[[f]]];]];
For[h = 1, h <= 54, h++,
If[kibaku[[h]] == 1 || bomblist[[h]] == 1, pattern[[h]] = 0;
numlist[[h]] = 0]]];];
chainflag = 0; While[chainflag == 0, chainflag = 1;
For[i = 48, i >= 1, i--, nullcount = 0;
If[pattern[[i]] != 0 ,
For[j = i + 6, j <= 54, j = j + 6,
If[pattern[[j]] == 0, nullcount += 1]]];
If[nullcount > 0, pattern[[i + 6*nullcount]] = pattern[[i]];
numlist[[i + 6*nullcount]] = numlist[[i]]; pattern[[i]] = 0;
numlist[[i]] = 0]]; erase = Table[0, 54]; chaincount = 0;
For[i = 1, i <= 54, i++,
If[pattern[[i]] != 0 && pattern[[i]] < 6,
For[j = 1, j <= Length[nextlist[i]], j++,
If[pattern[[nextlist[i][[j]]]] == pattern[[i]],
erase[[nextlist[i][[j]]]] = 1; chainflag = 0;
If[chaincount == 0, chain += 1; chaincount = 1];
If[numlist[[nextlist[i][[j]]]] != 0 &&
bombcheck[[nextlist[i][[j]]]] == 0,
Which[QuotientRemainder[nextlist[i][[j]], 6][[2]] == 1,
k1 += 1; bombwait1[[k1]] = numlist[[nextlist[i][[j]]]];
bombcheck[[nextlist[i][[j]]]] = 1,
QuotientRemainder[nextlist[i][[j]], 6][[2]] == 2, k2 += 1;
bombwait2[[k2]] = numlist[[nextlist[i][[j]]]];
bombcheck[[nextlist[i][[j]]]] = 1,
QuotientRemainder[nextlist[i][[j]], 6][[2]] == 3, k3 += 1;
bombwait3[[k3]] = numlist[[nextlist[i][[j]]]];
bombcheck[[nextlist[i][[j]]]] = 1,
QuotientRemainder[nextlist[i][[j]], 6][[2]] == 4, k4 += 1;
bombwait4[[k4]] = numlist[[nextlist[i][[j]]]];
bombcheck[[nextlist[i][[j]]]] = 1,
QuotientRemainder[nextlist[i][[j]], 6][[2]] == 5, k5 += 1;
bombwait5[[k5]] = numlist[[nextlist[i][[j]]]];
bombcheck[[nextlist[i][[j]]]] = 1,
QuotientRemainder[nextlist[i][[j]], 6][[2]] == 0, k6 += 1;
bombwait6[[k6]] = numlist[[nextlist[i][[j]]]];
bombcheck[[nextlist[i][[j]]]] = 1]]]]]];
bombcheck = Table[0, 54];
For[i = 1, i <= 54, i++,
If[erase[[i]] == 1, pattern[[i]] = 0; numlist[[i]] = 0]]];
If[chain > maxchain, maxchain = chain];
doubletimes = 0;
If[chain >= 5, doubletimes = chain - 4];
For[n = 1, n <= doubletimes, n++,
Which[oddsupinitial == 0,
rowodds[[oddsup1]] += basicrowodds[[oddsup1]]; oddsupinitial = 1,
oddsupinitial == 1,
rowodds[[oddsup2]] += basicrowodds[[oddsup2]]]];
bottom = {0, 0, 0, 0, 0, 0};
k = {k1, k2, k3, k4, k5, k6};
l = {0, 0, 0, 0, 0, 0};
bombwait = {bombwait1, bombwait2, bombwait3, bombwait4, bombwait5,
bombwait6};
For[i = 1, i <= 6, i++, l[[i]] = 9;
For[j = 48 + i, j >= 1, j = j - 6,
Which[pattern[[j]] == 0, bottom[[i]] = l[[i]], pattern[[j]] != 0,
l[[i]] = l[[i]] - 1]]];
For[i = 1, i <= 6, i++, m = 0;
For[j = l[[i]] - k[[i]] + 1, j <= l[[i]], j++, m += 1;
pattern[[6*j + i - 6]] = 6;
numlist[[6*j + i - 6]] = bombwait[[i, m]]]]];
eraseline = {0, 0, 0, 0, 0, 0};
For[a = 1, a <= 6, a++,
Which[pattern[[48 + a]] == 0, eraseline[[a]] = 1,
pattern[[48 + a]] != 0, eraseline[[a]] = 0]];
odds = Dot[eraseline, rowodds];
odds = FractionalPart[odds] + IntegerPart[odds];
If[eraseline == {1, 1, 1, 1, 1, 1}, odds += 50]; totalodds += odds;
PO = totalodds/times; oddslist[[game, times]] = odds;
If[odds > maxodds, maxodds = odds];
If[QuotientRemainder[times, 100][[2]] == 0,
Print[{game, times, maxchain, odds, PO, maxodds}]];];
For[i1 = 1, i1 <= 1000, i1++, j1 = 0.1*i1 - 0.1;
counter[[game, i1]] = Count[oddslist[[game]], j1]];
counter[[game, 1001]] = PO]
ウディタと違って視覚的に見づらいので2日くらいかかった。
これでまた解析を行う。