Как я могу изменить этот алгоритм решателя Lights Out, чтобы он учитывал произвольное количество недостающих плиток?Javascript

Форум по Javascript
Anonymous
Как я могу изменить этот алгоритм решателя Lights Out, чтобы он учитывал произвольное количество недостающих плиток?

Сообщение Anonymous »

Мой код: https://jsfiddle.net/03t2wdrq/

Код: Выделить всё

// based on https://www.keithschwarz.com/interesting/code/?dir=lights-out

var puzzle = [];
var toggle = [];
var solution = [];

// initialize toggle matrix where each cell in puzzle has a corresponding row
// each row in toggle is the same length as the total number of cells in the puzzle
// the true values in each row determain which tiles are toggled when a tile is pressed
// in this case, this is the pressed tile and each tile above, below, left, and right of it
function createToggle(p) {
let t = Array.from({length: area}, () => Array(area).fill(false));
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
for (let yOff = -1; yOff 

Подробнее здесь: [url]https://stackoverflow.com/questions/79343356/how-can-i-modify-this-lights-out-solver-algorithm-to-account-for-an-arbitrary-nu[/url]

Вернуться в «Javascript»