diff --git a/game.js b/game.js index bb7a69f..3d673b5 100644 --- a/game.js +++ b/game.js @@ -607,7 +607,7 @@ function nextLevel() { } function randomizeMaze() { - const modificationRate = 0.15; + const modificationRate = 0.1; const changes = Math.floor(ROWS * COLS * modificationRate); console.log('Modification aléatoire du labyrinthe,', changes, 'changements'); @@ -623,21 +623,13 @@ function randomizeMaze() { const currentCell = maze[y][x]; if (currentCell === WALL) { - if (Math.random() < 0.7) { + if (Math.random() < 0.9) { maze[y][x] = DOT; - } else { - maze[y][x] = EMPTY; } } else if (currentCell === EMPTY) { - if (Math.random() < 0.6) { - maze[y][x] = DOT; - } else if (Math.random() < 0.3) { - maze[y][x] = WALL; - } + maze[y][x] = DOT; } else if (currentCell === DOT) { - if (Math.random() < 0.3) { - maze[y][x] = EMPTY; - } else if (Math.random() < 0.1) { + if (Math.random() < 0.05) { maze[y][x] = WALL; } } @@ -645,22 +637,25 @@ function randomizeMaze() { for (let y = 1; y < ROWS - 1; y++) { for (let x = 1; x < COLS - 1; x++) { - if (maze[y][x] === WALL) { + if (maze[y][x] === EMPTY) { + maze[y][x] = DOT; + } else if (maze[y][x] === WALL) { const neighbors = [ maze[y-1][x], maze[y+1][x], maze[y][x-1], maze[y][x+1] ]; const wallCount = neighbors.filter(c => c === WALL).length; + const emptyCount = neighbors.filter(c => c === EMPTY).length; - if (wallCount === 0 && Math.random() < 0.4) { + if (wallCount === 0 && Math.random() < 0.7) { + maze[y][x] = DOT; + } else if (emptyCount >= 2 && Math.random() < 0.9) { maze[y][x] = DOT; - } else if (wallCount === 4 && Math.random() < 0.3) { - maze[y][x] = EMPTY; } } } } - console.log('Labyrinthe modifié aléatoirement'); + console.log('Labyrinthe modifié aléatoirement, tous les trous remplis'); } function placeBonuses() {