# 由于原始图像的某些部分丢失，难以解决相位滑动的难题[英] Difficult to solve the phaser sliding puzzle as some parts of the original image is missing

### 问题描述

```function prepareBoard() {

var piecesIndex = 0,
i, j,
piece;

BOARD_COLS = Math.floor(game.world.width / PIECE_WIDTH);
BOARD_ROWS = Math.floor(game.world.height / PIECE_HEIGHT);

piecesAmount = BOARD_COLS * BOARD_ROWS;

shuffledIndexArray = createShuffledIndexArray();

for (i = 0; i < BOARD_ROWS; i++)
{
for (j = 0; j < BOARD_COLS; j++)
{
if (shuffledIndexArray[piecesIndex]) {
piece = piecesGroup.create(j * PIECE_WIDTH, i * PIECE_HEIGHT, "background", shuffledIndexArray[piecesIndex]);
}
else { //initial position of black piece
piece = piecesGroup.create(j * PIECE_WIDTH, i * PIECE_HEIGHT);
piece.black = true;
}
piece.name = 'piece' + i.toString() + 'x' + j.toString();
piece.currentIndex = piecesIndex;
piece.destIndex = shuffledIndexArray[piecesIndex];
piece.inputEnabled = true;
piece.posX = j;
piece.posY = i;
piecesIndex++;
}
}

}

function createShuffledIndexArray() {

var indexArray = [];

for (var i = 0; i < piecesAmount; i++)
{
indexArray.push(i);
}

return shuffle(indexArray);

}

function shuffle(array) {

var counter = array.length,
temp,
index;

while (counter > 0)
{
index = Math.floor(Math.random() * counter);

counter--;

temp = array[counter];
array[counter] = array[index];
array[index] = temp;
}

return array;

}```

## 推荐答案

1. 总是缺少一个瓷砖，因为这是玩家可以用来滑动瓷砖的空白点.最常见的是，缺少的图块是图像右下角的图块.

1. 有些配置是无法解决的，也就是说，并不是每一个随机打乱的瓷砖情况都可以通过滑动瓷砖来解决.

```5 3 4
2 6 1
8 7
```

Photoscramble v2(下载包含 Delphi 源代码)
Photoscramble v1(下载包括 BlitzBasic 源代码)