October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Designing a Zero-Guess Puzzle Generator for Star Battle (Two Not Touch) Using Constraint Logic

A Star Battle generator needs three separate checks: a valid intended answer, exactly one formal solution, and a logic path that solves without guessing. Here is how to build and verify each one.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes, but only if the generator checks three separate guarantees: the board has a valid intended solution, the formal rules allow exactly one solution, and a declared set of human-style deductions finishes the board without assuming anything. Only the third justifies the term zero-guess. A uniqueness counter alone does not establish it, because a board can have one formal solution and still stall under a limited rule set. Star Battle, also called Two Not Touch, is the target format throughout.

The rules the generator must encode

A Star Battle board is an N×N grid divided into N regions. Each row, each column, and each region must contain exactly k stars, and no two stars may touch, including diagonally. A star therefore rules out its eight neighboring cells. Publishers vary board sizes and star counts. The reference implementation discussed below uses 1-star 8×8, 2-star 10×10, and 3-star 14×14 boards as its own conventions, not as requirements of the puzzle.

As an Amazon Associate I earn from qualifying purchases.

Cell states and the constraints behind them

Represent every cell as one of three values: UNKNOWN, STAR, or EMPTY. Every row, column, and region is an exactly-k constraint, and every placed star propagates to its eight neighbors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Three forced deductions

Each of the following rules follows from the constraints alone, so none of them is a guess.

  • Quota reached: if a line or region already holds k stars, every remaining unknown in it becomes EMPTY.
  • Quota forced: if the placed stars plus the remaining unknowns equal k, every unknown in that line or region becomes STAR.
  • Neighbor elimination: a newly placed star sets its eight neighbors to EMPTY.

Apply the rules repeatedly until no cell changes (a fixpoint) or one cell is required to be both a star and empty (a contradiction). On a 2-star board, for example, if a row holds one star and exactly one unknown remains, that unknown must be a star, because 1 + 1 = 2.

Building the answer first, then the puzzle

Generation runs in a fixed order. The stored answer comes first, because every later check measures the board against it.

  1. Choose parameters. Select N and k, then add any product requirements, such as contiguous regions, a preferred region shape, or a target difficulty band. Keep these as your own settings rather than as rules of Star Battle in general.
  2. Place a legal star layout. Put exactly k stars in each row and each column so that no two touch. A simple method is row-by-row backtracking: for each row, try cells whose column is not yet full and that do not touch an existing star, and step back when a row cannot be completed.
  3. Grow regions around the stars. Give each group of k stars its own region label, then grow each region through adjacent unassigned cells until every cell has a label. Stars never move, so each region keeps exactly k stars. The growth order is the main control over region shape.
  4. Run the deduction engine. Start from an all-UNKNOWN board that shows only the regions, and apply the declared rule set until the board is solved or stalls.
  5. Count solutions independently. Run a complete solver that stops after it finds two solutions. This check is separate from the deduction engine.
  6. Verify the intended answer. Confirm that the unique solution equals the stored layout and that every region is connected if your format requires contiguity. Then serialize the puzzle and its solution in one fixed format.
  7. Record a solve trace. Store which rule forced each star and elimination, and in what order. The trace supports hints, debugging, and difficulty reporting.

Unique does not mean zero-guess

Three checks answer three different questions, and a generator needs all of them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Check Question it answers How it is run Failure means
Formal validity Does the stored layout obey every rule? Verify quotas, the no-touch rule, region membership, and connectivity where required The board is invalid; regenerate it
Uniqueness How many assignments satisfy the formal rules? Complete search that stops at two solutions 0 means no solution; 2 means the board is ambiguous
Logic solvability Can the declared deductions finish the board? Propagate and apply the allowed tiers until the board is solved or stalls A stall means the board is not zero-guess under your definition

A board can pass the uniqueness check and fail the logic check. Such a board is unique but not zero-guess, and the second result is the one that matters for a zero-guess promise.

Choosing which deductions count

Name the strictest tier your product can honestly promise. Deduction tiers differ in how much they assume:

Tier Typical pattern Counts toward zero-guess?
Direct inference Quota reached, quota forced, neighbor elimination Yes, under any definition
Enumeration Exhaustive case analysis over the arrangements of a line or region, with no assumed cell value Only if your definition allows it; state that in the product description
Single-assumption hypothesis Assume one cell is a star, propagate, and look for a contradiction No under a strict definition; if you allow it, disclose that the solver branches once

Uniqueness counting without confusing it with difficulty

The uniqueness counter is a complete search. It propagates first and branches only when propagation stalls: it tries a cell as a star, then as empty, and recurses on each. A fully assigned board that passes the checks counts as one solution. Pruning is allowed only when it cannot discard a real solution, so the final count must cover the whole remaining search space.

One documented heuristic chooses the unknown in the line with the fewest remaining cells. That ordering can reduce search time but does not change what the count means.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function count_solutions(state, limit = 2):
    state = propagate(state)        // all quota and adjacency rules
    if contradiction(state): return 0
    if fully_assigned(state): return 1
    cell = choose_unknown(state)    // e.g. unknown in the line with fewest unknowns
    total = 0
    for value in [STAR, EMPTY]:
        total += count_solutions(assign(state, cell, value), limit - total)
        if total >= limit: break
    return total

Measuring difficulty without overclaiming

None of the public projects examined publishes a validated difficulty scale, so any score you show is a design choice. Report these axes separately rather than collapsing them into one number:

  • The strongest deduction tier the solve needed.
  • The number of forced placements and eliminations in the deterministic trace.
  • The length of the accepted solve path, in steps.
  • The search effort of the uniqueness counter, which is generator cost rather than player difficulty.

Label every score with the rule set and version that produced it, so a reader can reproduce it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the public implementations show

Four public repositories cover parts of this pipeline. Each is useful as a reference, but none establishes how a generator performs on arbitrary boards.

sen-ltd/star-battle

A TypeScript implementation with three sets of exactly-k units, eight-way adjacency, propagation to a fixpoint, backtracking uniqueness counting, and a generator that places stars and then grows regions. Its README describes a small bundled set of solver-verified boards and a test that re-solves generated puzzles and compares the recovered stars with the drawn answer. That is a useful self-check, but it covers only the boards it bundles.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

masonomara/star-battle

A production-rules document that organizes human-style deductions into direct inferences, tiling and counting enumerations, and hypothetical deductions. Its vocabulary helps define what each tier means in your own product, but it is one project’s design rather than a formal standard.

MelodyLucien/starbattle

A browser-based generator with region partitioning, a uniqueness check that stops after two solutions, and print-friendly output. Its README gives generation timings for selected configurations. Those figures are self-reported and have not been independently benchmarked, so they do not support a general performance claim.

smjw/StarBattle

A student project covering generation, solving, and difficulty assessment. Its overview does not describe a difficulty formula in enough detail to reuse, so build the scoring from the axes above.

Failure modes and recovery

  • The uniqueness counter returns 0. The stored layout or the region map breaks a rule. Check quotas, the no-touch rule, and region membership on the stored answer, and regenerate if any check fails.
  • The counter returns 2 or more. The region map admits an alternative layout. Move a non-star boundary cell from one region to a neighboring region, keeping both regions connected, then recount. Confirm that the stored answer is still the unique solution.
  • The counter returns 1, but the deduction engine stalls. The board is unique but not zero-guess under your declared rules. Regenerate the regions, or, if your product allows a hypothetical tier, change the stated definition and label the board accordingly.
  • The engine completes with a different layout from the stored answer. With a unique solution and sound rules, a completed solve must match it, so a mismatch points to a bug in one rule. Compare each rule’s output against the solve trace to find it.
  • A region becomes disconnected after an edit. Reject the edit if your format requires contiguous regions, and check connectivity after every boundary change.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.