A Battleship JavaScript design needs a unique shot set and separate hit membership for each ship. A sunk result follows the last previously unhit cell of that ship, and a fleet win follows every ship's completed membership.
Use this original six-by-six, two-ship teaching activity to inspect those transitions. It models one-sided fleet hunting, with no opponent attacks or ship-placement editor. The local HTML example implements this bounded activity; verify its behavior in the intended host. It is not a complete multiplayer board game.

Keep the variant and coordinate system explicit
The University of Arizona's archived assignment models half a Battleship board and distinguishes first guesses, repeated guesses, per-ship sinking and the all-ships end state. Its ten-by-ten fleet, Python files and source examples are not this activity's layout. Arizona: Battleship Assignment
Use zero-based row/column coordinates 0–5, with rows increasing downward. Avoid mixing these with the source's x/y convention. There are thirty-six learner cells, initially unknown.
| Original ship | Length | Occupied cells |
|---|---|---|
| S1 | 3 | (1,1), (1,2), (1,3) |
| S2 | 2 | (3,4), (4,4) |
The fleet occupies five distinct cells. S1 is a consecutive horizontal segment; S2 is a consecutive vertical segment. No overlap exists, and all cells are inside the declared board. These coordinates are a separate developer fixture, not labels shown on the learner's unknown cells.
Before accepting this fixed fixture, validate integer bounds, unique ship IDs, declared lengths, consecutive straight membership and nonoverlap. A malformed fixture is a setup error, not a learner miss or an empty fleet win.
Client-side source can expose the fleet to inspection. Hiding its values in the learner view is not secrecy, anti-cheat protection or a private answer service. There is no random-placement difficulty claim.
Send every attack through one transaction
Provide thirty-six native coordinate-labeled buttons. An optional row/column entry control calls exactly the same attack function, with an explicit Attack button. Reject empty, fractional, nonnumeric or out-of-range coordinates before making a cell key.
An accepted new coordinate enters the unique shot set once. If no ship occupies it, mark a miss. If a ship occupies it, add that coordinate to that ship's unique hit set and derive its remaining cells from membership.
Check the shot set before changing any hit set. A repeat reports Already attacked and retains the previous result. It cannot increase shots, hits, sunk ships or progression. The same rule applies to repeated misses, not only repeated hits.
Keep these counters distinct: unique shots across the board; unique hit coordinates across ships; sunk ships; ships remaining. A three-cell ship has one identity, three possible hits, and one sinking transition.
Trace the repeat before the sinking shot
Use this original independent sequence from the initial fleet:
| Action | New result | Unique shots | Unique hits | Sunk ships |
|---|---|---|---|---|
| Attack (1,1) | Hit S1 | 1 | 1 | 0 |
| Attack (1,1) again | Repeat; retain hit | 1 | 1 | 0 |
| Attack (0,0) | Miss | 2 | 1 | 0 |
| Attack (1,2) | Hit S1 | 3 | 2 | 0 |
| Attack (1,3) | S1 sunk | 4 | 3 | 1 |
| Attack (3,4) | Hit S2 | 5 | 4 | 1 |
| Attack (4,4) | S2 sunk; fleet complete | 6 | 5 | 2 |
Seven attack actions produce six unique shots because one repeats. Five unique hits cover the five occupied cells; the remaining unique shot is the miss at (0,0). Ships remaining goes from two to one after S1, then zero after S2.
The repeat at (1,1) cannot stand in for the missing (1,2) or (1,3). After S1 sinks, another attack on one of its cells likewise cannot produce a second sinking event. Derive sunk state from all member cells hit, and report the transition only when a new attack changes that ship from not sunk to sunk.
Make the board read from the same sets
Show Unknown, Hit, Miss and Sunk with symbols and text as well as color. At sinking, the ship's already-hit cells can change their label from Hit to Sunk S1 or Sunk S2. Do not reveal unhit cells or unrelated ships by treating a partial hit as the entire fleet.
The cell view reads shot membership and per-ship state. Counters read those same sets. A separate mutable displayed hit counter cannot silently disagree with the authoritative five-cell fleet.
Keep focus usable after attacks. If attacked cells become disabled, explicitly place focus somewhere useful rather than losing the keyboard position. This bounded design may leave them focusable so a repeat gives its nonmutating explanation. Test that policy with keyboard activation and touch; it is not a conformance claim.
If optional text coordinates are used, enter row and column separately with visible 0–5 bounds. Empty text is invalid rather than automatically zero. A displayed validation message does not change the board or count as a shot.
Finish once and restore the same fleet
After both ships are sunk, enter terminal Fleet complete. Ignore further attacks, including valid unknown coordinates, until Reset. The result retains six unique shots and five unique hits for the specified sequence; it cannot continue accumulating misses after the win.
Reset restores the original fixed fleet, thirty-six unknown cells, empty shot and hit sets, zero shots/hits/sunk ships, two ships remaining, and cleared terminal/feedback state. Invalidate pending callbacks before restoring it so an old result announcement cannot sink a ship in a new activity.
There is no missile budget or automatic loss for a miss in this design. A player can continue making unique legal attacks until the fleet is found. Adding a budget, second player or placement editor later would require a new state model and tests, rather than an unsupported feature promise in this packet.
Copy this prompt to specify the native activity
Create an original self-contained HTML/CSS/JavaScript one-sided fleet-hunt teaching file, complete native source and manual test matrix. Reference https://www2.cs.arizona.edu/classes/cs120/fall17/ASSIGNMENTS/assg06/battleship.html for unique guesses, hit/miss, per-ship sunk and all-ships end concepts only. No copied Python/files, source fleet, artwork or ship names. No opponent attacks, AI, placement editor, missile budget, network, storage, multiplayer or protected-answer guarantee.
Original 6×6 board, zero-based row/column 0–5, rows downward. S1 length 3 occupies (1,1),(1,2),(1,3); S2 length 2 occupies (3,4),(4,4). Five distinct occupied cells, consecutive straight ships, no overlap. Validate fixed setup bounds, IDs, lengths and straight/nonoverlap structure; invalid setup is an error, not a miss or win. Learner sees 36 unknown coordinate buttons, not fleet values. Client source remains inspectable.
One attack function serves native cells and optional separate row/column inputs. Reject empty, noninteger, nonnumeric or out-of-range values without mutation. Check terminal state and unique shot membership before updates. New shots enter one set; misses mark empty cells; hits add unique coordinate membership to the relevant ship. Repeats retain prior hit/miss and report already attacked without new counts or sinking.
Per-ship sunk state is derived from all member cells being hit. Announce sinking once on a new not-sunk→sunk transition. Fleet win requires both ships sunk. Counters derive from unique shots, union of unique hits and sunk ship identities; ships remaining is 2 minus sunk ships. Views use symbols/text, not only color; sunk cells derive from that same state.
Independent sequence: (1,1) hit; repeat (1,1) no change; (0,0) miss; (1,2) hit; (1,3) sinks S1; (3,4) hits S2; (4,4) sinks S2 and completes fleet. Final six unique shots, five unique hits, two sunk ships, zero remaining. Seven action events are not seven shots. Repeating a sunk cell cannot resink it.
Terminal ignores all further attacks until Reset. Reset restores original fleet, 36 unknown cells, empty shot/per-ship hit sets, zero counters, two ships remaining and cleared terminal/feedback; invalidate old callbacks. Keep useful focus; focusable attacked cells may explain repeats without mutation. Provide full instructions and coordinate bounds. Test repeats on hit/miss/sunk cells, all table states, invalid inputs/setup, counter consistency, terminal guards, Reset/stale callbacks and keyboard/touch behavior. Check actual article width and 360 px without page overflow. Report performed versus proposed tests honestly. Native source and fixture remain authoritative; optional NOS explanation promises no saved progress, export, secret fleet or automatic updates, and hosted controls require actual verification.
Keep the shot trace beside the source
Maintain the native source, original fleet, unique-shot trace and actual test results together. A reviewer should be able to distinguish a repeated hit from a new hit and explain why six unique shots complete this fleet.
NOS can save and render HTML. A prepared HTML explanation can show those original hit-set and sinking transitions beside the maintained source. Actual hosted attacks, focus, counters and Reset need verification before claiming a working game example.
Explore NOS with the fleet review. The useful result accounts for each attacked coordinate once and each ship's actual occupied cells.