1function tour(board, moves) {
2 if (moves.length === n*n) return true;
3 for (const move of getMoves(moves.last)) {
4 if (board[move] === 0) {
5 moves.push(move); board[move] = 1;
6 if (tour(board, moves)) return true;
7 moves.pop(); board[move] = 0; // 回溯
8 }
9 }
10 return false;
11}