Skip to content

Commit ec8bc90

Browse files
committed
Misc improvements to solver/generator visualization
1 parent fc9e155 commit ec8bc90

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

Diff for: pics.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
set -e
44

5+
perl solve_from_db.pl expert 95; perl vis.pl < foo > solver.svg
6+
57
MAP_HEIGHT=10 MAP_WIDTH=10 PIECES=20 cmake . && make
68
bin/mklinjat --puzzle_count=1 --seed=90210 --solve_progress_file=progress-opt.json --score_cover=1 --score_cant_fit=3 --score_square=50 --score_dep=100 --score_one_of=60 --score_max_width=-1
79
perl vis.pl < progress-opt.json > progress-opt.svg
810

9-
MAP_HEIGHT=8 MAP_WIDTH=8 PIECES=15 cmake . && make
11+
MAP_HEIGHT=10 MAP_WIDTH=10 PIECES=16 cmake . && make
1012
bin/mklinjat --puzzle_count=1 --seed=90210 --candidate_progress_file=dots-opt.json --score_cover=1 --score_cant_fit=3 --score_square=50 --score_dep=100 --score_one_of=60 --score_max_width=-1 --optimize_iterations=0
1113
perl vis.pl < dots-opt.json > dots-opt.svg
1214

15+
perl solve_from_db.pl easy 4; perl vis.pl < foo > unique.svg
16+
17+
for i in solver progress-opt dots-opt unique; do
18+
rsvg-convert < $i.svg > $i.png
19+
convert $i.png -scale 480 $i-thumb.png
20+
done

Diff for: solve_from_db.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
die if system "MAP_HEIGHT=$h MAP_WIDTH=$w PIECES=$p cmake . && make ";
2020
my $res = qx(bin/mklinjat --solve="$str" --solve_progress_file=foo);
21-
21+
print $res;
22+
my $json = decode_json $res;
23+
print $json->{classification}{'single-solution'}{depth};
2224

2325

Diff for: src/main.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -1118,14 +1118,15 @@ Game add_forced_squares(Game game, FILE* fp) {
11181118
if (game.force_if_uncontested() && fp)
11191119
game.print_json(fp, "\"type\":\"ambiguate\",");
11201120
auto res = game.iterate();
1121-
if (fp)
1122-
game.print_json(fp, "");
11231121
if (res.first == DeductionKind::NONE) {
11241122
if (!game.force_one_square()) {
11251123
break;
11261124
}
11271125
if (fp)
11281126
game.print_json(fp, "\"type\":\"add dot\",");
1127+
} else {
1128+
if (fp)
1129+
game.print_json(fp, "");
11291130
}
11301131
if (game.impossible()) {
11311132
break;

Diff for: vis.pl

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ sub draw_board {
2121
my $hwidth = $width / 2;
2222

2323
if ($board->{type}) {
24-
print "<text x='$hwidth' y='18' text-anchor='middle' fill='black' class='number'>$board->{type}</text>";
24+
print "<text x='$hwidth' y='18' text-anchor='middle' fill='black' class='text'>$board->{type}</text>";
2525
}
2626
if (exists $board->{iter}) {
27-
print "<text x='5' y='18' text-anchor='left' fill='black' class='snumber'>Iteration: $board->{iter}</text>";
27+
print "<text x='5' y='18' text-anchor='left' fill='black' class='text'>Iteration: $board->{iter}</text>";
2828
}
2929
if (exists $board->{score}) {
30-
print "<text x='$hwidth' y='18' text-anchor='middle' fill='black' class='snumber'>Score: $board->{score}</text>";
30+
print "<text x='$hwidth' y='18' text-anchor='middle' fill='black' class='text'>Score: $board->{score}</text>";
3131
}
3232
print "<g transform='translate(5, 21)'>";
3333
print "<rect x='0' y='0' height='$height' width='$width' stroke='black' stroke-width='2' fill='white'/>";
@@ -75,8 +75,10 @@ sub draw_board {
7575

7676
print qq(<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
7777
<style>
78-
.number { font: bold 28px sans-serif; }
78+
.number { font-size: 28px; }
79+
.text { font-size: 16px; }
7980
</style>
81+
<rect width="100%" height="100%" fill="white"></rect>
8082
);
8183

8284
my $x_offset = 5;

0 commit comments

Comments
 (0)