-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINPUT.html
140 lines (127 loc) · 5.96 KB
/
INPUT.html
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<title>INPUT - Random Intelligence Test</title>
<style>
html, body {
background-color: rgba(16, 16, 32, 1.0);
color:#FFFFFF;
font-size:16px;
width: 100%;
height: 100%;
}
a:link, a:visited {
color: #0FF;
text-align: center;
text-decoration: none;
display: inline-block;
}
.f16 {font-size: 16pt; color: #0F0;}
.F16 {font-size: 16pt; color: #0FF;}
</style>
<body>
<table width=100% heigth=100%>
<tbody>
<tr>
<td width=15%> </td>
<td width=70%>
<p align=left class=f16>
Let’s play RIT:<br><a href="https://github.com/ogrnv/random-intelligence-tests" target="_blank">https://github.com/ogrnv/random-intelligence-tests</a><br><br>
There is only one player in the game - you, so you should take the first move!<br><br>
Let TB be given board with chips or the board with chips after your move(s), TB[address] be an integer assigned to a cell with the address: zero mean an empty cell, non-zero mean a chip marked with the integer on the cell.<br><br>
Let EM be a relocation of a chip to a horizontally or vertically adjacent zero cell. As a result of this relocation, the values of TB[from] and TB[to] should swap.<br><br>
Every game move must be either an EM or a sequence of several EMs. Let the move start address be SA and the move finish address be FA. Please note: FA must not be equal to SA. Let move number be MN.<br><br>
The goal of the game is to complete it in the fewest number of moves. The game ends after <b><span id="STEPS"></span></b> step(s).
A step ends when YOU by your last move, complete a formation of a straight horizontal or vertical or diagonal line of five or more chips with the same marking. After completing the step, you will receive and must use TB board with these updates:
five successive chips are removed from the line (for cases with long or/and several line(s) it is done randomly), then five previously presented chips are randomly added to the free cells of the board.<br><br>
For the sake of certainty, let in an cell address [i,j], i be the row number, j be the column number and both be numbered from zero.</p><p align=left class=F16>
The board with chips is:<br></p>
<p align=left class=F16 id="CELLS"></p>
<p align=left class=F16>The next five chips: <span id="NEXT5"></span></p>
<p align=left class=f16>
Please, disable any output other than printing the MN, SA, FA and the board after each move. Print SA and FA in a format similar this example: SA=[0,1] FA=[2,3] without any additions.<br>
Wait my input after each your move. It could be:<br>
a status line indicating the number of moves and steps;<br>
ok - your move is counted. If only SA, FA are used to check your move, you can compare your last board with a verified board that will be provided. I recommend using the verified board. In any case go to the next move;<br>
b ??? - wrong, decrease MN by 1 and come back. The last good TB will be provided;<br>
s - a step completed. An updated board with chips and, if needed, five new random chips will be provided;<br>
F - the game is over.<br>
where ??? is a reason of the error.
<br><br>THE END OF THE TEST TASK</p>
<p align=left class=F16>
Board size=<span id="HM"></span><br>
Empty cells number=<span id="EMB"></span><br>
Number of types of chips=<span id="KCB"></span><br>
Steps in one test=<span id="STEPSS"></span><br></b><br><br><br></p>
<script>
var hm=8, //size of a side of square table/board.
kcb=2, //how many of one digit types of chips are placed on the table
emb=10, //number of empty sells 22=64-42
stp=2; //number of steps that stops test
var Cells = [];
//you can insert a string below with any separators or without them
var Cells_string =`
1,1,2,0,2,1,2,1
0,1,2,0,1,1,2,1
1,1,0,2,2,2,1,1
2,1,2,2,2,2,2,1
1,2,2,1,2,2,0,2
1,1,0,2,0,2,1,0
2,1,1,2,1,2,2,1
0,2,2,2,0,2,2,2
`;
//separator must be a comma:
var n5 = [1,1,2,1,1];
let n=0, va, nk=[0, 0,0,0, 0,0,0, 0,0,0];// number of types of chips
let nt=0, cs = Cells_string.replace(/[^0-9]/g, "");
if(cs.length != hm*hm)
{alert ("Check hm and number of digits in Cells_string");
throw new Error("");
}
for (i = 0; i < hm; i++){
Cells[i] = [];
for (j = 0; j < hm; j++){
Cells[i][j] = va = Number(cs.substring(n, n+1)); n++;
if (va>0 && nk[va]==0) nt++;
nk[va]++;
}
}
if(nt>kcb) {alert ("Number of types of chips in Cells_string is > " + kcb); throw new Error("")}
if(nt<kcb) alert ("Warning: number of types of chips in Cells_string = " + nt);
if(nk[0]!=emb) {
alert ("Number of zeroes in Cells_string is not = " + emb);
throw new Error("");
}
document.getElementById("HM").innerHTML = hm;
document.getElementById("EMB").innerHTML = emb;
document.getElementById("KCB").innerHTML = kcb;
var s = ""; for (i=0; i<hm; i++) s=s+Cells[i]+"<br>";
document.getElementById("CELLS").innerHTML = s;
s = ""; for (i=0; i<4; i++) s=s+n5[i]+","; s=s+n5[4];
document.getElementById("NEXT5").innerHTML = s;
document.getElementById("STEPS").innerHTML = stp;
document.getElementById("STEPSS").innerHTML = stp;
//https://stackoverflow.com/questions/2144386/how-to-delete-a-cookie
document.cookie = 'hm=; Max-Age=-99999999;';
document.cookie = 'kcb=; Max-Age=-99999999;';
document.cookie = 'emb=; Max-Age=-99999999;';
document.cookie = 'cs=; Max-Age=-99999999;';
document.cookie = 'mn=; Max-Age=-99999999;';
document.cookie = 'qn=; Max-Age=-99999999;';
document.cookie = 'stp=; Max-Age=-99999999;';
document.cookie = 'n5=; Max-Age=-99999999;';
document.cookie = 'tb=; Max-Age=-99999999;';
document.cookie = "hm="+hm;//size of a side of square table/board.
document.cookie = "kcb="+kcb;//how many of types of chips are placed on the table
document.cookie = "emb="+emb;//number of empty sells 22=64-42
document.cookie = "mn=0";//number of moves
document.cookie = "qn=0";//number of finished lines >4 chips long
document.cookie = "stp="+stp;//number of steps in the test
document.cookie = "cs="+cs;
sc=""; sc=n5; cs=sc.toString().replace(/[^0-9]/g, "");
document.cookie = "n5="+cs;
</script>
</td><td width=15%> </td></tr></tbody>
</table>
</body>
</html>