omega-feel
This project has not described itself yet.
Brought by drakestapleton
omega-feel / evidence / round40-cpu / replay-input.wl
| 1 | HH = 12; NMIN = 32; NMAX = 256; VV = 3; REST0 = 1024; RESTMAX = 65536; WARM = 64; |
| 2 | run[K_, data_] := Module[{status = ConstantArray[0, K], inc = 0, mode = 0, rest = WARM, restlen = REST0, |
| 3 | next = 0, ch = -1, vcount = 0, k = 0, w = 0, l = 0, sI = 0, sC = 0, hI = 0, hC = 0, n = 0, pend = False, |
| 4 | tfirst = 0, z = 1, o = 0, events = {}, counts = ConstantArray[0, K], arm, shadow, a, found, tI, tC, t, d, |
| 5 | out, i = 0, ns, okmask, start}, |
| 6 | (* mode: 0 rest, 1 shadow, 2 duel *) |
| 7 | status[[1]] = 1; |
| 8 | start[] := (mode = 2; k = 0; w = 0; l = 0; sI = 0; sC = 0; hI = 0; hC = 0; n = 0); |
| 9 | Do[ |
| 10 | i++; {ns, okmask} = row; shadow = -1; pend = False; arm = inc; |
| 11 | If[mode == 0, |
| 12 | If[rest > 0, rest--, |
| 13 | found = -1; |
| 14 | Do[a = Mod[next + s, K]; If[found < 0 && a != inc && status[[a + 1]] != 2, found = a], {s, 1, K}]; |
| 15 | If[found < 0, rest = restlen, |
| 16 | ch = found; next = found; |
| 17 | If[status[[ch + 1]] == 0, mode = 1; vcount = 0, start[]]]]]; |
| 18 | If[mode == 1, shadow = ch]; |
| 19 | If[mode == 2, |
| 20 | If[EvenQ[k], z = Mod[z*1103515245 + 12345, 2^31]; o = BitGet[z, 16]]; |
| 21 | arm = If[(EvenQ[k] && o == 0) || (OddQ[k] && o == 1), inc, ch]; pend = True]; |
| 22 | counts[[arm + 1]]++; |
| 23 | If[shadow >= 0, |
| 24 | If[BitGet[okmask, shadow] == 0, |
| 25 | status[[ch + 1]] = 2; AppendTo[events, {"B", ch, i}]; mode = 0; rest = restlen, |
| 26 | vcount++; If[vcount == VV, status[[ch + 1]] = 1; AppendTo[events, {"M", ch, i}]; start[]]]]; |
| 27 | If[pend, |
| 28 | t = ns[[arm + 1]]; |
| 29 | If[EvenQ[k], tfirst = t, |
| 30 | If[arm == ch, tC = t; tI = tfirst, tC = tfirst; tI = t]; |
| 31 | sI += tI; sC += tC; If[tC < tI, w++]; If[tC > tI, l++]; n++; |
| 32 | If[n == NMAX/2, hI = sI; hC = sC]; |
| 33 | out = ""; |
| 34 | Which[ |
| 35 | n >= NMIN && l - w >= HH && sC >= sI, out = "R", |
| 36 | n >= NMAX, out = Which[ |
| 37 | hC < hI && sC - hC < sI - hI && w - l >= HH, "A", |
| 38 | 64 hC < 63 hI && 64 (sC - hC) < 63 (sI - hI), "Am", |
| 39 | True, "D"]]; |
| 40 | If[out != "", |
| 41 | AppendTo[events, {out, ch, i, n, w, l, sI, sC}]; |
| 42 | If[out == "A" || out == "Am", inc = ch; restlen = REST0, restlen = Min[2 restlen, RESTMAX]]; |
| 43 | rest = restlen; mode = 0]]; |
| 44 | k++], {row, data}]; |
| 45 | {events, {"F", inc, restlen, counts, status}}]; |
| 46 | |
| 47 | {First[run[2,{{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{1569551,0},3},{{0,3672692},3},{{1564463,0},3},{{0,2560889},3},{{0,2546841},3},{{1518735,0},3},{{0,2647978},3},{{1546383,0},3},{{0,2539064},3},{{1518335,0},3},{{0,2958893},3},{{1517598,0},3},{{1543199,0},3},{{0,2536968},3},{{0,2564090},3},{{1501599,0},3},{{1577360,0},3},{{0,2550922},3},{{1554015,0},3},{{0,3928807},3},{{0,2623722},3},{{1596351,0},3},{{0,2551721},3},{{1533935,0},3},{{1496302,0},3},{{0,2557817},3},{{1544223,0},3},{{0,2547177},3},{{0,2554969},3},{{1525999,0},3},{{0,6237197},3},{{1542879,0},3},{{0,3502978},3},{{1633968,0},3},{{0,2547513},3},{{2154981,0},3},{{0,3734197},3},{{1553407,0},3},{{1495535,0},3},{{0,2536441},3},{{1535487,0},3},{{0,2544489},3},{{1530335,0},3},{{0,2656282},3},{{0,2537129},3},{{1557407,0},3},{{0,2542648},3},{{1543903,0},3},{{0,2547593},3},{{1558768,0},3},{{1768017,0},3},{{0,2673194},3},{{0,2685131},3},{{1557279,0},3},{{0,2567001},3},{{1632416,0},3},{{1565231,0},3},{{0,2560570},3},{{1797089,0},3},{{0,2541545},3},{{1592400,0},3},{{0,2543705},3},{{0,2552841},3},{{1661488,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3}}]],First[run[2,{{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},1},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3},{{0,0},3}}]]} |