Skip to content

Add structural Board→text renderer and integrate it into run_solver - #225

Draft
semiexp with Copilot wants to merge 4 commits into
mainfrom
copilot/add-text-conversion-function
Draft

Add structural Board→text renderer and integrate it into run_solver#225
semiexp with Copilot wants to merge 4 commits into
mainfrom
copilot/add-text-conversion-function

Conversation

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

run_solver previously had no compact text output for solved boards. This change adds a backend-side text renderer that infers rendering from Board structure, focuses on answer data (green items), and returns None for unsupported board/item patterns.

  • Board text rendering API

    • Added Board::to_text() -> Option<String> in cspuz_solver_backend/src/board.rs.
    • Rendering is structure-driven (cell/edge placement by coordinate parity), not puzzle-specific branching.
    • Supported answer glyphs are centered on green items (e.g. block/dot/number/square and line/cross-style edges).
    • Unsupported green item kinds, conflicting placements, or invalid coordinates return None.
    • Updated edge rendering to show continuous borders (+---+) for dot-grid boards (e.g. slitherlink), while keeping non-dot-grid boards (e.g. yajilin) on the original spacing-based renderer to avoid malformed output.
  • run_solver integration

    • Updated cspuz_solver_backend/src/bin/run_solver.rs to print text output in non-JSON mode when to_text() returns Some(...).
    • Existing --json behavior remains unchanged.
  • Coverage for required puzzle families

    • Added focused tests to ensure to_text() is produced for required puzzle URLs (nurikabe, fillomino, slitherlink, yajilin, heyawake, dbchoco, evolmino).
    • Added a negative test verifying unsupported item kinds return None.
    • Added regression tests for:
      • dot-grid continuity (+---+) on slitherlink
      • preventing dot-grid-style + vertex rendering from leaking into yajilin output
// run_solver.rs (non-JSON path)
println!("Answer Status: {}", answer_status);
if let Some(text) = board.to_text() {
    println!("\n{}", text);
}

@semiexp

semiexp commented Apr 17, 2026

Copy link
Copy Markdown
Owner

@copilot

Answer Status: Unique

    x   x   x   |   x
  -   x   x   x   -   x
    |   x   x   x   |
  x   -   x   -   x   x
    |   |   |   |   |
  -   x   -   x   -   x
    |   |   |   |   x
  x   -   x   -   -   -
    |   x   x   x   |
  x   -   -   -   x   x
    x   x   x   |   |

見づらいです。+---+ のように、境界線が途切れなく見えるようにしてください

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Answer Status: Unique

...

対応しました。連続した境界線になるように Board::to_text の描画ロジックを更新し、+---+ 形式で表示されるようにしています(commit: aa377f2)。

Screenshot (run_solver output):

Answer Status: Unique

+---+---+---+---+
|   x   x   x   |
+---+ x +---+ x +
x   |   |   |   |
+---+ x + x + x +
|   x   |   |   |
+ x +---+ x +---+
|   |   x   x   x
+---+ x + x + x +

Copilot AI requested a review from semiexp April 17, 2026 03:17
@semiexp

semiexp commented Apr 17, 2026

Copy link
Copy Markdown
Owner

@copilot

Answer Status: Unique

    +   +   +   +   +           +   +
  . | . | . x . | . | .   #   . | . | .
+---+ x +---+---+ x +---+   +---+   +---+
  . | . x . | . x . | . x . | .   #   .
    +---+   +   +---+   +---+       +---+
  #   .   #       .       .   #       .
    +---+   +   +---+   +---+   +   +---+
      . x . | . | .   #   . | . x . | .
    +---+---+   + x +   + x +---+---+
  . | . x .       . | . | . x . x .
+---+ x +---+   +---+   +---+---+---+
  . | . x .   #   .   #   . x . x . | .
    +---+---+   +---+   +---+---+   +---+
  #   . x .       .       . x .       .
    +---+---+   +---+   +---+---+   +---+
  . | . x . | . | .   #   . | .   #   .
+---+ x + x + x + x +   + x +       +---+
  . x . | . | . | . x . | .       . | .
+---+---+   +   +---+---+---+   +---+
  . | .       #   . | . x . | . | .   #
    +               +   +   +   +

yajilin を入れたらこうなりましたが、描画が明らかにおかしいです。修正してください

Agent-Logs-Url: https://github.com/semiexp/cspuz_core/sessions/2ef9c45d-1854-44ac-b6af-38bc52cc350e

Co-authored-by: semiexp <7336994+semiexp@users.noreply.github.com>

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Answer Status: Unique

...

修正しました。+---+ の連続境界レンダリングは DotGrid のみに限定し、Yajilin など非 DotGrid は従来の配置ベース描画に戻しています(commit: 45fa1d0)。

Screenshot (run_solver output, yajilin):

Answer Status: Unique

  . | . | . x . | . | .   #   . | . | .
  -   x   -   -   x   -       -       -
  . | . x . | . x . | . x . | .   #   .
      -           -       -           -
  #   .   #       .       .   #       .
      -           -       -           -
      . x . | . | .   #   . | . x . | .
      -   -       x       x   -   -
  . | . x .       . | . | . x . x .
  -   x   -       -       -   -   -
  . | . x .   #   .   #   . x . x . | .
      -   -       -       -   -       -
  #   . x .       .       . x .       .
      -   -       -       -   -       -
  . | . x . | . | .   #   . | .   #   .
  -   x   x   x   x       x           -
  . x . | . | . | . x . | .       . | .
  -   -           -   -   -       -
  . | .       #   . | . x . | . | .   #

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.

2 participants