@@ -137,7 +137,7 @@ function plot_killer(grid, sums, fname; fill = true, mark = nothing)
137
137
png (" /home/ole/Julia/ConstraintSolver/visualizations/images/$(fname) " )
138
138
end
139
139
140
- function plot_str8ts (grid, white, fname)
140
+ function plot_str8ts (grid, white, fname; search_space = nothing , only_fixed = true )
141
141
plot (;
142
142
size = (900 , 900 ),
143
143
legend = false ,
@@ -148,83 +148,21 @@ function plot_str8ts(grid, white, fname)
148
148
149
149
for r= 1 : 9 , c= 1 : 9
150
150
plot! (
151
- rectangle (1 , 1 , r - 1 , 9 - c ),
151
+ rectangle (1 , 1 , c - 1 , 9 - r ),
152
152
color = white[r,c] == 1 ? " white" : " black" ,
153
153
)
154
+ x = c - 0.5
155
+ y = 10 - r - 0.5
154
156
if grid[r,c] != 0
155
- x = r - 0.5
156
- y = 10 - c - 0.5
157
- annotate! ([x, y, text (string (grid[r,c]), 20 , white[r,c] == 1 ? :black : :white )])
157
+ annotate! (x, y, text (string (grid[r,c]), 20 , white[r,c] == 1 ? :black : :white ))
158
158
end
159
- end
160
- #=
161
- for s in sums
162
- ind = s.indices[1]
163
- x = ind[2] - 0.75
164
- y = 10 - ind[1] - 0.17
165
- annotate!(x, y, text(s.result, 15, :black))
166
- if mark === nothing
167
- for ind in s.indices
168
- plot!(rectangle(1, 1, ind[2] - 1, 9 - ind[1]), color = s.color, alpha = 0.4)
169
- end
170
- else
171
- for ind in s.indices
172
- if ind in mark
173
- plot!(
174
- rectangle(1, 1, ind[2] - 1, 9 - ind[1]),
175
- color = "red",
176
- alpha = 0.4,
177
- )
178
- else
179
- plot!(
180
- rectangle(1, 1, ind[2] - 1, 9 - ind[1]),
181
- color = s.color,
182
- alpha = 0.4,
183
- )
184
- end
185
- end
186
- end
187
- end
188
-
189
- for i in [3, 6]
190
- plot!([i, i], [0, 9], color = :black, linewidth = 4)
191
- end
192
- for j in [3, 6]
193
- plot!([0, 9], [j, j], color = :black, linewidth = 4)
194
- end
195
-
196
-
197
- if fill
198
- for ind in keys(grid)
199
- if CS.isfixed(grid[ind])
200
- x = ind[2] - 0.5
201
- y = 10 - ind[1] - 0.5
202
- annotate!(x, y, text(value(grid[ind]), 20, :black))
203
- else
204
- vals = values(grid[ind])
205
- sort!(vals)
206
- x = ind[2] - 0.3
207
- y = 10 - ind[1] - 0.2
208
- max_idx = min(3, length(vals))
209
- text_vals = join(vals[1:max_idx], ",")
210
- annotate!(x, y, text(text_vals, 11))
211
- if length(vals) > 3
212
- y -= 0.25
213
- max_idx = min(6, length(vals))
214
- text_vals = join(vals[4:max_idx], ",")
215
- annotate!(x, y, text(text_vals, 11))
216
- end
217
- if length(vals) > 6
218
- y -= 0.25
219
- max_idx = length(vals)
220
- text_vals = join(vals[7:max_idx], ",")
221
- annotate!(x, y, text(text_vals, 11))
222
- end
223
-
159
+ if search_space != = nothing
160
+ if search_space[r,c] != 0 && (search_space[r,c] isa Int || length (search_space[r,c]) == 1 )
161
+ @assert white[r,c] == 1
162
+ annotate! (x, y, text (string (search_space[r,c]), 20 , :blue ))
224
163
end
225
164
end
226
165
end
227
- =#
228
166
229
167
png (" /home/ole/Julia/ConstraintSolver/visualizations/images/$(fname) " )
230
168
end
0 commit comments