JSFiddle - React, Tailwind, and code Playground
HTML
<p>Очки — среднее число пустых ячеек за 1000 запусков, меньше — лучше.</p>
<table id="scoretable">
<thead>
<tr>
<td></td>
<td>Участник</td>
<td>Очки(min/max)</td>
<td>Ошибки</td>
<td>Время</td>
</tr>
</thead>
</table>
CSS
#scoretable {
font-size: 16px;
line-height: 1.4;
border-collapse: collapse;
}
#scoretable thead td {
font-weight: 700;
border-bottom: 1px solid #ccc;
}
#scoretable td {
padding: 5px 30px 5px 5px;
}
#scoretable tr:nth-child(even) {
background: #f5f5f5;
}
JavaScript
var contenders = {
'SiDChik': function (w, h, cols) {
function can_place(w, h, pos){
if ((cols[pos]+h) > 20) return false;
if ((pos + w) > 10) return false;
// Solid Placement?
var errors = 0;
var heights = cols.slice(pos, pos+w);
var maxH = Math.max.apply(Math, heights);
for (var i=0;i<heights.length;i++){
if (heights[i]!=maxH) errors+=1;
}
return errors;
}
var move = 0;
for (var maxError=0; maxError < w; maxError++){
if (move) break;
var minH = 100;
for (var i=0; i<10; i++){
var tmp = can_place(w, h, i)
if (tmp === maxError){
if (cols[i] < minH) {
move = i+1;
minH = cols[i];
}
}
}
}
if (!move){
console.log('PAnic');
move = getRandomInt(1, 6);
}
return move
},
'bay73': function(w, h, cols) {
if(w==1) {
if(cols[5] < cols[4]) return 6;
if(cols[8] < cols[9]) return 9
else if(cols[9] <= 16) return 10;
else if(cols[4] <= 16) return 5;
else if(cols[3] < cols[2]) return 4;
else if(cols[2] < cols[1]) return 3;
else if(cols[1] < cols[0]) return 2;
else return 1;
}
if(w==2) {
if(cols[2] < cols[0]) return 3;
else if(cols[4] < cols[0]) return 5;
else if(cols[0] < cols[2]) return 1;
else if(cols[6] <= 18) return 7;
else if(cols[4] < 12) return 5;
else if(cols[4] < 18 && cols[9] < 16) return 5;
else if(cols[0] <= 17) return 1;
else if(cols[4] <= 18) return 5;
else return 9;
}
if(w==4) {
if(cols[0]<20) return 1;
else if(cols[1]<20) return 2;
else return 3;
}
},
'tigerforce': function(w, h, cols) {
...