Skip to content

Commit

Permalink
add data
Browse files Browse the repository at this point in the history
  • Loading branch information
revolt3245 committed Nov 12, 2023
1 parent bc7f6de commit ec3f949
Show file tree
Hide file tree
Showing 166 changed files with 3,831 additions and 911 deletions.
2 changes: 1 addition & 1 deletion BnW_Picross/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
- `bnw_picross_solver`: 가장 최근 버전의 피크로스 솔버
- `Test`: 피크로스 솔버 초기버전
- `Test2`: 피크로스 솔버에 memoization 기법 적용
- `Test3`: 귀류법 적용 (작성중)
- `Test3`: 귀류법 적용
13 changes: 11 additions & 2 deletions BnW_Picross/Test3/+Parameter/get_parameter.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
r_const = sscanf(fline, "%d");
end

out_param.row_const{i, 1} = r_const';
if r_const == 0
out_param.row_const{i, 1} = [];
else
out_param.row_const{i, 1} = r_const';
end
end

for i=1:out_param.n_col
Expand All @@ -40,7 +44,12 @@

c_const = sscanf(fline, "%d");
end
out_param.col_const{i, 1} = c_const';

if c_const == 0
out_param.col_const{i, 1} = [];
else
out_param.col_const{i, 1} = c_const';
end
end
fclose(fid);
end
49 changes: 0 additions & 49 deletions BnW_Picross/Test3/+Solver/backtrack_solver.asv

This file was deleted.

29 changes: 20 additions & 9 deletions BnW_Picross/Test3/+Solver/backtrack_solver.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
function [state, flag] = backtrack_solver(param, state, graphics)
%% find minimum line
line_num = 0;
min_n_line = inf;
min_upper_bound = inf;
for i = 1:(param.n_row + param.n_col)
if i <= param.n_row
if(any(state.row_const{i}) && (min_n_line > state.n_lines(i)))
min_n_line = state.n_lines(i);
line_width = state.bounds(2, i) - state.bounds(1, i) + 1;
clue_width = sum(param.row_const{i}(state.bounds(3,i):state.bounds(4,i)));
clue_size = state.bounds(4,i) - state.bounds(3,i) + 1;

upper_bound = line_width - clue_width - clue_size + 2;
if(any(state.row_const{i}) && (min_upper_bound > upper_bound))
min_upper_bound = upper_bound;
line_num = i;
end
else
if (any(state.col_const{i-param.n_row}) && (min_n_line > state.n_lines(i)))
min_n_line = state.n_lines(i);
line_width = state.bounds(2, i) - state.bounds(1, i) + 1;
clue_width = sum(param.col_const{i-param.n_row}(state.bounds(3,i):state.bounds(4,i)));
clue_size = state.bounds(4,i) - state.bounds(3,i) + 1;

upper_bound = line_width - clue_width - clue_size + 2;

if (any(state.col_const{i-param.n_row}) && (min_upper_bound > upper_bound))
min_upper_bound = upper_bound;
line_num = i;
end
end
Expand All @@ -26,7 +37,7 @@
if line_num <= param.n_row
line_width = gh_bound - gl_bound + 1;
first_clue = param.row_const{line_num}(cl_bound);
upper_bound = line_width - first_clue;
upper_bound = line_width - first_clue + 1;

for i=1:upper_bound
if i == 1
Expand Down Expand Up @@ -58,7 +69,7 @@
else
line_width = gh_bound - gl_bound + 1;
first_clue = param.col_const{line_num-param.n_row}(cl_bound);
upper_bound = line_width - first_clue;
upper_bound = line_width - first_clue + 1;

for i=1:upper_bound
if i == 1
Expand Down Expand Up @@ -92,7 +103,7 @@
if line_num <= param.n_row
line_width = gh_bound - gl_bound + 1;
first_clue = param.row_const{line_num}(cl_bound);
upper_bound = line_width - sum(param.row_const{line_num}(cl_bound:ch_bound)) - size(param.row_const{line_num}) + 2;
upper_bound = line_width - sum(param.row_const{line_num}(cl_bound:ch_bound)) - size(param.row_const{line_num}(cl_bound:ch_bound)) + 2;

for i=1:upper_bound
if i == 1
Expand Down Expand Up @@ -126,7 +137,7 @@
else
line_width = gh_bound - gl_bound + 1;
first_clue = param.col_const{line_num-param.n_row}(cl_bound);
upper_bound = line_width - sum(param.col_const{line_num - param.n_row}) - size(param.col_const{line_num-param.n_row}) + 2;
upper_bound = line_width - sum(param.col_const{line_num - param.n_row}(cl_bound:ch_bound)) - size(param.col_const{line_num-param.n_row}(cl_bound:ch_bound), 2) + 2;

for i=1:upper_bound
if i == 1
Expand Down
2 changes: 2 additions & 0 deletions BnW_Picross/Test3/+Util/fill_line_memo.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
end

o_line = memo(1,:);
elseif s_clues == 0
o_line = ones(1, s_line, 'uint8');
else
[~, memo(:, clues(1)+2:end)] = Util.fill_line_memo(i_line(clues(1)+2:end), clues(2:end), memo(:, clues(1)+2:end));
for i=1:upper_bound
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions BnW_Picross/Test3/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
fig = figure(Name="picross");
ax = gca;

param = Parameter.get_parameter(file="samples/30/sample2.txt", ...
save_video=true);
param = Parameter.get_parameter(file="test3.txt", ...
save_video=false);
state = State.get_initial_state(param);
graphics = Draw.initialize(fig, ax, 0.5, param);

Expand Down
63 changes: 63 additions & 0 deletions BnW_Picross/Test3/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
16 35

9
6 3 3

3 3 3 2
2 3 2 5
1 3 2 3 1
5 2 3 2
11 2 2 3

2 10 1 4
1 5 3 2 3 1
12 3 1 3 2 4
1 7 1 1 3 4 1
2 4 2 1 4 2 4 3

1 1 1 3 3 4
3 4 2 9 5
1 2 5
3 4

2
1 1 2
3 3 1
2 2 1 1
2 4 2

4 5 2
2 7 1
1 8 1 1
2 7 3
1 1 2 2 2

1 2 1 4
2 3 3 1
3 4 2
4 4 3
1 2 3 1

2 1 2 1 3
3 1 1 1
4 4 1
1 2 2 1 1
1 1

1 2 1
2 4 1 1
1 3 2 1
4 3 3
2 3 2

5 2 2
7 1
2 1
3
4

1 1
4
3
1 1
2
55 changes: 55 additions & 0 deletions BnW_Picross/Test3/test2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
25 20

0
10
14
16
18

18
20
1 15
1 1
1 1

1 4 4 1
1 2 2 2 2 1
1 2 2 1
1 2 1 2 1
1 2 1

1 2 1
1 1 1
1 3 1
1 1
1 1

1 2 2 1
2 2 2 2
3 8 3
2 2
12

16
3 2
4 1 1
5 2 2
5 1 2 1 2

7 1 2 2 1
7 2 2 1
7 1 1 1
7 1 1
7 2 1 1 1

7 2 1 1 1
7 3 1 1
7 1 1 1
7 2 2 1
7 1 2 2 1

6 1 2 1 2
6 2 2
5 1 1
4 2
16
46 changes: 46 additions & 0 deletions BnW_Picross/Test3/test3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
17 20

0
0
0
3 1
2 5

3 2
3 1
2 1 1
1 1 2
4 1 2

2 3 2
3 1 6 2
1 5
2 1 2 2
3 1 1 3

2 1 1 1 5
20

2
1 2
2 1
2 2 1
2 2 1

1 1 3
3 1
2 2 1
1 1 2 3
1 2 2 1 1

2 2 1 1
2 2 1
1 6
2 3 1
1 1 1

2 2 2
1 3 2
2 3 3
4 4
4
Loading

0 comments on commit ec3f949

Please sign in to comment.