B:BD[
6.24990] → [
6.24990:25098]
B:BD[
6.25182] → [
6.25182:25298]
B:BD[
6.25382] → [
6.25382:25498]
B:BD[
6.25582] → [
6.25582:25699]
B:BD[
6.25790] → [
6.25790:25902]
B:BD[
6.26118] → [
6.26118:26139]
∅:D[
3.69] → [
6.26211:26913]
B:BD[
6.26211] → [
6.26211:26913]
B:BD[
6.26913] → [
3.70:108]
∅:D[
3.108] → [
6.26914:26974]
B:BD[
6.26914] → [
6.26914:26974]
B:BD[
6.26974] → [
3.109:173]
∅:D[
3.173] → [
6.26974:27189]
B:BD[
6.26974] → [
6.26974:27189]
B:BD[
6.27189] → [
3.174:228]
∅:D[
3.228] → [
6.27189:29842]
B:BD[
6.27189] → [
6.27189:29842]
[1, 0],
[2, 0],
[3, 0],
[4, 0],
[5, 0],
[6, 0],
[7, 0],
[8, 0],
[0, 1],
[0, -1],
[0, -2],
[0, -3],
[0, -4],
[0, -5],
[0, -6],
[0, -7],
[0, -8],
[3, 1],
[3, -1],
[3, -2],
[3, -3],
[3, -4],
[3, -5],
[3, -6],
[3, -7],
[3, -8],
[6, 1],
[6, -1],
[6, -2],
[6, -3],
[6, -4],
[6, -5],
[6, -6],
[6, -7],
[6, -8],
[-3, 1],
[-3, -1],
[-3, -2],
[-3, -3],
[-3, -4],
[-3, -5],
[-3, -6],
[-3, -7],
[-3, -8],
];
let order2 = [];
for (let x = -3; x <= 8; ++x) {
for (let y = -10; y <= 1; ++y) {
order2.push([x, y]);
}
}
// from https://stackoverflow.com/a/2450976
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
//shuffle(order2);
for (let e of order2) {
order.push(e);
}
let minx = 1000;
let miny = 1000;
let maxx = -999;
let maxy = -999;
let alreadyPlaced = new Set(["0,0"]);
while (placedIds.size < 144) {
for (let pos of order) {
if (alreadyPlaced.has(pos[0] + ',' + pos[1])) continue;
let cands = listCandidates(pos[0], pos[1]);
//console.log(cands.length, 'candidates');
if (cands.length == 1) {
placements.push(cands[0]);
placedIds.add(cands[0].id);
alreadyPlaced.add(pos[0] + ',' + pos[1]);
let x = cands[0].x;
let y = cands[0].y;
//console.log('placed', cands[0].id, 'at', x, y);
if (x < minx) minx = x;
if (y < miny) miny = y;
if (x > maxx) maxx = x;
if (y > maxy) maxy = y;
} else if (cands.length == 0) {
//console.log("no candidates for ", pos);
}
}
}
let product = 1;
for (let pl of placements) {
if (pl.x == maxx && pl.y == maxy) {
product *= pl.id;
}
if (pl.x == minx && pl.y == maxy) {
product *= pl.id;
}
if (pl.x == maxx && pl.y == miny) {
product *= pl.id;
}
if (pl.x == minx && pl.y == miny) {
product *= pl.id;
}
}
console.log(product);
let combinedBorderedImage = [];
let combinedImage = [];
for (let x = 0; x < 12 * 10; ++x) {
let row = [];
for (let y = 0; y < 120; ++y) {
row.push('~');
}
combinedBorderedImage.push(row);
}
for (let x = 0; x < 12 * 8; ++x) {
let row = [];
for (let y = 0; y < 96; ++y) {
row.push('~');
}
combinedImage.push(row);
}
for (let pl of placements) {
for (let x = 0; x < 10; ++x) {
for (let y = 0; y < 10; ++y) {
combinedBorderedImage[(pl.y - miny) * 10 + y][(pl.x - minx) * 10 + x] = pl.t[y][x];
}
}
}
for (let row of combinedBorderedImage) {
//console.log(row.join(''));
}
for (let pl of placements) {
for (let x = 1; x < 9; ++x) {
for (let y = 1; y < 9; ++y) {
combinedImage[(pl.y - miny) * 8 + y - 1][(pl.x - minx) * 8 + x - 1] = pl.t[y][x];
}
}
}
for (let row of combinedImage) {
//console.log(row.join(''));
}
let monster =[
" # ",
"# ## ## ###",
" # # # # # # "];
function testForMonster(tile, x, y) {
let squares = 0;
for (let i = 0; i < 3 && i + y < 96; ++i) {
for (let j = 0; j < 20 && j + x < 96; ++j) {
if (monster[i][j] == ' ') continue;
if (tile[i+y][j+x] == ' ') return 0;
if (monster[i][j] == '#' && tile[i+y][j+x] == '#') {
squares++;
}
}
}
if (squares < 15) return 0;
return squares;
}
let min = 10000;
for (let variant of gen_orientations(combinedImage)) {
let otherTiles = 0;
let foundAny = false;
for (let x = 0; x < 96; ++x) {
for (let y = 0; y < 96; ++y) {
if (variant[y][x] == '#') otherTiles++;
let c = testForMonster(variant, x, y);
if (c > 0) foundAny = true;
otherTiles -= c;
}
}
if (otherTiles < min) min = otherTiles;
}
console.log(min);