-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIRST.html
138 lines (136 loc) · 5.73 KB
/
FIRST.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
<!DOCTYPE html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<title>FIRST - 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
<br><br><br>
</p>
<script>
var hm=8, //size of a side of square table/board.
kcb=2, //how many of 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 = [];
for (i = 0; i < hm; i++){
Cells[i] = [];
for (j = 0; j < hm; j++){
Cells[i][j] = 0;
}
}
var n5 = [];
for (i = 0; i < 5; i++){n5[i] = 0;}
function random(min, max) {
var mi = Math.ceil(min), ma = Math.floor(max);
return Math.floor(Math.random()*(ma-mi+1)+mi);
}
/*
function random(min, max) {//https://stackoverflow.com/a/65440696
const range = max - min + 1
const bytes_needed = Math.ceil(Math.log2(range) / 8)
const cutoff = Math.floor((256 ** bytes_needed) / range) * range
const bytes = new Uint8Array(bytes_needed)
let value
do {
crypto.getRandomValues(bytes)
value = bytes.reduce((acc, x, n) => acc + x * 256 ** n, 0)
} while (value >= cutoff)
return min + value % range
}
*/
function newdesk(){
var i, j;
for (i = 0; i < hm; i += 1){
for (j = 0; j < hm; j += 1){
Cells[i][j]=random(1, kcb);
}
}
//empty emb cells
n=0;
while(n<emb){
i=random(0, hm - 1);
j=random(0, hm - 1);
if(Cells[i][j]>0){Cells[i][j] = 0; n++;}
}
n=0;
while(n<5){
n5[n]=random(1, kcb);
n++;}
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;
}
newdesk();
//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
let cs="";
let sc=""; sc=Cells; cs=sc.toString().replace(/[^0-9]/g, "");
document.cookie = "cs="+cs;
sc=""; sc=n5; cs=sc.toString().replace(/[^0-9]/g, "");
document.cookie = "n5="+cs;
//let x2 = document.cookie;
</script>
</td><td width=15%> </td></tr></tbody>
</table>
</body>
</html>