My intention is to create PuzzleGame, example http://migo.sixbit.org/puzzles/fifteen/
Main priority is to move Cells from one with value, to another one undefined.
Here is my function:
moveCell(row, col) {
this.puzzleTable = [];
let actRow = 0,
actCol = 0;
for (let r = -1; r <= 1; r++) {
actRow = row + r;
if (actRow >= 0 && actRow < this.rowCount) {
moveCells(this.puzzleTable[actRow][col], row, actRow);
}
}
for (let c = -1; c <= 1; c++) {
actCol = col + c;
if (actCol >= 0 && actCol < this.colCount) {
moveCells(this.puzzleTable[row][actCol], col, actCol);
}
}
}
For example:
Arr[0][0] to Arr[1][1]
I do not want to change their value, I want them swap
What is the best practice ?