|
Download task_050/instruction.md from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 2.24 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_050/instruction.md
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_050/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_050/instruction.md
2.24 kB
Build a playable Reversi board
Create a single offline index.html for Reversi (Othello). Render a uniform 8×8 board with clickable cells and a display of the turn, piece counts and outcome. DOM, canvas or SVG rendering is fine.
Interface
Expose window.__game with init(), setState(board, turn), getState(), legalMoves() and play(r,c). Use zero-based coordinates.
- A board is an 8×8 array of
'B','W'andnull. Start with white at[3,3]and[4,4], black at[3,4]and[4,3]; Black moves first. init,setStateandplayreturn the resulting state.getState()returns{board,turn,status,counts:{B,W},winner}, with statusplayingorover, and winner null while playing orB,Wordrawwhen over.legalMoves()returns all legal positions for the current turn as[r,c]pairs, in any order, or an empty list when the game is over.- Use
data-testidvaluesboard,count-b,count-w,turn,status,winnerandnew-gamefor the corresponding elements. Put the decimal count, turn symbol, and status value alone in their respective elements; explanatory labels can sit outside them. The New Game button resets the opening.
Acceptance Checklist
- A move into an empty cell is legal only if it brackets one or more consecutive opponent pieces with a friendly piece along at least one of eight directions. Place the piece and flip every bracketed piece along all such directions. An occupied or non-flipping move leaves the board and turn unchanged.
- After a valid move, switch turns, passing back automatically if the opponent cannot move. If neither can move, end the game even on a non-full board. The higher piece count wins; equal counts draw.
setStateimmediately recognizes a position with no moves for either side as terminal. If only the specified side has no moves, retain that turn for inspection with an empty move list; automatic passing is part ofplay, not single-sided state injection.- Neither the supplied board nor a returned state shares mutable arrays with the engine. Real clicks and API calls update the same visible discs, turn and counts; status and winner reflect terminal positions. The offline page runs without browser errors.