Match the symbols!
Targets:{" "}
{answers.map((a, i) => {
if (i == currentAnswerIndex)
return (
{a}
);
return (
{a}
);
})}
{grid.map((line, y) => (
{line.map((cell, x) => {
const isCorrectAnswer = cell === answers[currentAnswerIndex];
if (x == pos[0] && y == pos[1]) {
return (
{cell}
);
}
const optionColor = hasAugment && !isCorrectAnswer ? Settings.theme.disabled : Settings.theme.primary;
return (
{cell}
);
})}
))}
>
);
}
function generateAnswers(grid: string[][], difficulty: Difficulty): string[] {
const answers = [];
for (let i = 0; i < Math.round(difficulty.symbols); i++) {
answers.push(grid[Math.floor(Math.random() * grid.length)][Math.floor(Math.random() * grid[0].length)]);
}
return answers;
}
function randChar(): string {
return "ABCDEF0123456789"[Math.floor(Math.random() * 16)];
}
function generatePuzzle(difficulty: Difficulty): string[][] {
const puzzle = [];
for (let i = 0; i < Math.round(difficulty.height); i++) {
const line = [];
for (let j = 0; j < Math.round(difficulty.width); j++) {
line.push(randChar() + randChar());
}
puzzle.push(line);
}
return puzzle;
}