in src/gemini_95/index.ts [1254:1279]
function placeMines(firstClickRow: number, firstClickCol: number) {
console.log(`Placing ${minesweeperMineCount} mines, avoiding ${firstClickRow},${firstClickCol}`);
let minesPlaced = 0;
while (minesPlaced < minesweeperMineCount) {
const r = Math.floor(Math.random() * minesweeperGridSize.rows);
const c = Math.floor(Math.random() * minesweeperGridSize.cols);
// Don't place a mine on the first clicked cell or if it already has a mine
if ((r === firstClickRow && c === firstClickCol) || grid[r][c].isMine) {
continue;
}
grid[r][c].isMine = true;
minesPlaced++;
}
// Calculate adjacent mines for all cells
for (let r = 0; r < minesweeperGridSize.rows; r++) {
for (let c = 0; c < minesweeperGridSize.cols; c++) {
if (!grid[r][c].isMine) {
grid[r][c].adjacentMines = countAdjacentMines(r, c);
}
}
}
console.log("Mines placed and adjacent counts calculated.");
}