Skip to content

Custom answer check area#205

Draft
m-ender wants to merge 20 commits into
swaroopg92:devfrom
m-ender:feature/answer-check-area
Draft

Custom answer check area#205
m-ender wants to merge 20 commits into
swaroopg92:devfrom
m-ender:feature/answer-check-area

Conversation

@m-ender
Copy link
Copy Markdown
Contributor

@m-ender m-ender commented Oct 30, 2025

This PR adds a new feature which would let puzzle authors define a custom area to which answer check applies. Anything a solver notates outside of this area would get ignored by the answer checker. If we want a short name for this feature (for UI purposes), "Mask" could work.

  • The answer check area is defined by a list of cells and a boolean indicating whether to include or exclude the boundary of those cells.
  • Add a new row to puzzle data in the URL to store and load this data.
  • When loading a puzzle (in solve mode) that doesn't have answer check area defined, or has an empty answer check area, it defaults to every cell in the grid (regardless of whether it's in centerlist), and includes the boundary.
  • On newly created puzzles, it defaults to the cells contained in centerlist and includes the boundary.
  • Add a toggle to display the answer check area (at least in edit mode), similar to the Visibility toggle. For square grids, the answer check area is rendered in the style of a cage (or several), probably with thick dots and in some colour.
  • Add a simpler style using semi-transparent shading for other grid types for now.
  • Add a new (Mask?) mode to edit the answer check area (probably next to Box). The mode contains a toggle for include/exclude boundary and otherwise lets you click (and drag) cells to toggle whether or not they're part of the area (similar to Box).
  • "Erase selected mode" in the new Mask mode should delete the entire answer check area (effectively disabling the feature and reducing URL length).
  • Make sure transforming the grid (rotate, reflect, grow, shrink) updates the answer check area correctly.
  • Editing the centerlist via Box mode should be reflected in the answer check area as well, unless the answer check area is empty.
  • Editing the centerlist via the Transform menu should be reflected in the answer check area as well, unless the answer check area is empty.
  • Internally convert this list of cells and the boolean to a list of all nodes that get checked. These always include all the cells in the area (as well as the corner/side number nodes in those cells), all edges touching two cells in the area, and all vertices surrounded by cells in the area. If the boundary is included, we also check edges and vertices that touch at least one cell in the area.
  • Elements which only have a single coordinate (Surface, Number, Shape) simply get answer checked if their node is in the above list.
  • Elements which have two coordinates (Line, Edge, Wall) get answer checked if at least one of their nodes is in the above list. (Yes, free lines and edges might pass through the area without getting answer checked if both endpoints lie outside.)

Nice to have:

  • Add buttons to Mask mode to grow/shrink the answer check area by entire rows/columns at a time.
  • Add button to Mask mode to reset the area to match the centerlist.
  • Show a warning if the (authoring) user has solution elements outside the answer check area.
  • A user setting to determine whether the answer check area should start out matching the centerlist, or empty (to disable the feature, essentially). The former should be the default.
  • Hide the mask visibility toggle in solve mode when there is no answer check.
  • Cage-style rendering of the mask on other grid types.

@m-ender m-ender force-pushed the feature/answer-check-area branch from 1b5a454 to 48cd87e Compare November 2, 2025 23:31
Comment thread docs/js/class_p.js Outdated
@marknn3
Copy link
Copy Markdown
Contributor

marknn3 commented Nov 18, 2025

Add a toggle to display the answer check area

Make the 'mask' mode always display the answer check area. Because I had difficulty to use this new feature because it apparently did nothing... I had to read the code to discover there actually was a new toggle to show its effect.
And when the mask mode always displays the area, it is IMHO not necessary anymore to have a dedicated toggle (less clutter), which has only a niche use-case anyways.

@m-ender
Copy link
Copy Markdown
Contributor Author

m-ender commented Nov 18, 2025

Add a toggle to display the answer check area

Make the 'mask' mode always display the answer check area. Because I had difficulty to use this new feature because it apparently did nothing... I had to read the code to discover there actually was a new toggle to show its effect. And when the mask mode always displays the area, it is IMHO not necessary anymore to have a dedicated toggle (less clutter), which has only a niche use-case anyways.

Good point. I'm inclined to keep the toggle anyway, so (a) it's easier to reference the answer check area while editing other things and (b) to view it in solve mode. But you're right, it should definitely always show up in Mask mode.

@swaroopg92
Copy link
Copy Markdown
Owner

It says, this PR is still a work in progress, so I believe you are still working on this?
If you have already polished it further, then please go ahead and finalize the draft to full PR.
Thank you.

@m-ender
Copy link
Copy Markdown
Contributor Author

m-ender commented Apr 17, 2026

Hm, I think I probably just forgot to remove the draft label, but I guess it depends on whether you think any of the optional todos at the bottom list should be done before merging this.

@swaroopg92
Copy link
Copy Markdown
Owner

swaroopg92 commented Apr 17, 2026

@m-ender
Alright, taking a look at the todos, although all are nice to have ideas, but i think, following would be a nice finish to get this merged:

  • Show a warning if the (authoring) user has solution elements outside the answer check area.
  • Hide the mask visibility toggle in solve mode when there is no answer check.

Later if you have bandwidth, feel free to work on others but these 2 would suffice for this merge.
May also resolve the conflicts while you are at it.
Thank you for all the great work.

@ReverM
Copy link
Copy Markdown
Contributor

ReverM commented May 28, 2026

Might be worth waiting for my cage PR for the rendering given how much it changes stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants