|
Download task_048/instruction.md from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_048/instruction.md
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_048/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_048/instruction.md
2.28 kB
Build an interactive Minesweeper game
Create a single offline index.html in HTML/CSS/JavaScript. Provide a visible board, status, size selector and New Game button.
Controls and state API
- Use
data-testid="board","status","grid-size"and"new-game"on the corresponding elements. Put the state value (playing,wonorlost) as text in the status element; any explanatory label can sit outside it. Mark every cell with zero-baseddata-randdata-c. Left-click reveals; right-click toggles a flag. Display a text symbol in flagged cells. - The selector shows dimensions, including 5×5, 8×8 and 12×12; option values may vary. Default to 5×5.
- Expose
window.__gamewithinit(config),getState(),reveal(r,c)andtoggleFlag(r,c). The three actions return the resulting state and drive the visible board. initaccepts{rows,cols,mines?}. Missing dimensions use the current selected size. Whenminesis supplied, use exactly those zero-based[r,c]positions. When omitted, sample distinct positions uniformly, with at least one mine and at least one safe cell; consecutive same-size games must not repeat the complete layout.getState()returns an independent JSON snapshot{rows,cols,status,cells}, withstatusequal toplaying,wonorlost;cellsis a row-major array of{revealed,flagged,mine,adj}. The first three cell fields are booleans andadjis the number of mines among eight neighbors.
Acceptance Checklist
- A new game uses the selected size, renders the full grid, and starts with every cell hidden and unflagged. Number labels, flags and the status are readable; cells are visible and do not overlap.
- Revealing a zero-count cell opens its connected zero region and adjacent numbered boundary cells, using the eight-neighbor grid and never propagating through numbers. Hidden flags toggle on and off, and revealing a flagged cell has no effect.
- Revealing a mine sets and displays
lostand reveals every mine. Revealing all safe cells sets and displayswon. Once ended, further reveal or flag actions do not change the board. - Visible actions and API calls update the same board. Changing the returned state cannot alter it; the game runs without browser errors or external dependencies.