Skip to content

Commit

Permalink
08ed6ac7
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed May 1, 2023
1 parent 76ebcc4 commit 6f88104
Show file tree
Hide file tree
Showing 17 changed files with 338 additions and 248 deletions.
4 changes: 2 additions & 2 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@

% we alias these so we can catch out of control list growth

my_append(A,B):- append(A,B).
my_append(A,B,C):- append(A,B,C). % ,check_len(A),check_len(C),check_len(C).
%append(A,B):- append(A,B).
%append(A,B,C):- append(A,B,C). % ,check_len(A),check_len(C),check_len(C).
gappend(A,B):- append(A,B).
gappend(A,B,C):- append(A,B,C). % ,check_len(A),check_len(C),check_len(C).
check_len(_).
Expand Down
14 changes: 7 additions & 7 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_alephlib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
%retractall(M:bgc(_)),
% (M:bg(BG0)->
% retract(M:bg(BG0)),
% my_append(BG0,L,BG),
% append(BG0,L,BG),
% arc_assert(M:bg(BG))
% ;
% assert_all(L,M,_)
Expand Down Expand Up @@ -276,7 +276,7 @@
% (M:in(IN0)->
% retract(M:in(IN0)),%
%
% my_append(IN0,L,IN),
% append(IN0,L,IN),
% arc_assert(M:in(IN))
% ;
% arc_assert(M:in(L))
Expand Down Expand Up @@ -332,7 +332,7 @@
% (M:in(IN0)->
% retract(M:in(IN0)),

% my_append(IN0,L,IN),
% append(IN0,L,IN),
% arc_assert(M:in(IN))
% ;
% arc_assert(M:in(L))
Expand Down Expand Up @@ -11158,29 +11158,29 @@
special_consideration(record,true,M):-
noset(recordfile_stream,M),
(setting(recordfile,F,M) ->
aleph_open(F,my_append,Stream),
aleph_open(F,append,Stream),
set(recordfile_stream,Stream,M);
true), !.
special_consideration(record,false,M):-
noset(recordfile_stream,M), !.
special_consideration(recordfile,File,M):-
noset(recordfile_stream,M),
(setting(record,true,M) ->
aleph_open(File,my_append,Stream),
aleph_open(File,append,Stream),
set(recordfile_stream,Stream,M);
true), !.
special_consideration(good,true,M):-
noset(goodfile_stream,M),
(setting(goodfile,F,M) ->
aleph_open(F,my_append,Stream),
aleph_open(F,append,Stream),
set(goodfile_stream,Stream,M);
true), !.
special_consideration(good,false,M):-
noset(goodfile_stream,M), !.
special_consideration(goodfile,File,M):-
noset(goodfile_stream,M),
(setting(good,true,M) ->
aleph_open(File,my_append,Stream),
aleph_open(File,append,Stream),
set(goodfile_stream,Stream,M);
true), !.
special_consideration(minscore,_,M):-
Expand Down
34 changes: 20 additions & 14 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
forall_count(all_suite_test_name(TestID),time(cache_devel(TestID)))).

cache_devel:- with_pair_mode(entire_suite,
forall_count(all_arc_test_name_unordered(TestID),
forall(all_arc_test_name_unordered(TestID),
((test_name_output_file(TestID,'.pl',File), ( exists_file(File)-> true; cache_devel(TestID)))))).
%cache_devel(TestID):- ensure_test(TestID), test_name_output_file(TestID,'.pl',File),
% catch(cant_rrtrace(notrace(cache_devel(TestID,File))),E,wdmsg(cache_devel(TestID,File)=E)),!.
Expand All @@ -108,9 +108,10 @@
%cache_devel(_TestID,File):- exists_file(File), !, writeln(exists_file(File)),!.
cache_devel( TestID,File):-
ensure_test(TestID),
alarm(180, halt(666), Id, [install(true),remove(false)]),
nl,writeq(starting(cache_devel( TestID,File))),nl,
sformat(S,'touch "~w"',[File]), shell(S),
call_with_time_limit(180.0,time(cache_devel_1(TestID))),
% sformat(S,'touch "~w"',[File]), shell(S),
cache_devel_1(TestID),
if_t(has_individuals(TestID),
((writeln(save_test_hints(TestID,File)),
save_test_hints_now(TestID,File),
Expand Down Expand Up @@ -711,30 +712,35 @@
some_min_unifier_3(A,[B|List],O):- must_min_unifier(A,B,C), some_min_unifier_3(C,List,O).

is_a_min_unifier(A,B,C):- B==strict,A==loose,!,C=A.
is_a_min_unifier(A,_,C):- A==fg,B\==bg,B\==wbg,!,C=A.
is_a_min_unifier(A,B,C):- A==fg,B\==bg,B\==wbg,!,C=A.
is_a_min_unifier(A,_,C):- plain_var(A),!,C=A.
is_a_min_unifier(A,B,C):- compound(A),A=trim(BB),B==BB,!,C=A.

min_unifier(A,B,C):- A=@=B,!,C=A.
min_unifier(A,B,C):- is_a_min_unifier(A,B,C).
min_unifier(B,A,C):- is_a_min_unifier(A,B,C).
min_unifier(A,B,C):- is_a_min_unifier(A,B,C),!.
min_unifier(B,A,C):- is_a_min_unifier(A,B,C),!.
min_unifier(A,B,C):- min_unifier_u(A,B,C),!.
/*
min_unifier(A,B,A):- plain_var(B),!.
min_unifier(A,B,B):- plain_var(A),!.
*/

min_unifier(A,B,D):- number(A),number(B),!,c_proportional(A,B,D).
min_unifier(A,B,AA):- is_grid(A),is_grid(B),!,min_grid_unifier(A,B,AA),!.
min_unifier(A,B,AA):- is_list(A),is_list(B),!,min_list_unifier(A,B,AA),
min_unifier_n(A,B,D):- number(A),number(B),!,c_proportional(A,B,D).
min_unifier_n(A,B,D):- min_unifier_u(A,B,D).



min_unifier_u(A,B,_):- (\+ compound(A);\+ compound(B)),!.
min_unifier_u(A,B,AA):- is_grid(A),is_grid(B),!,min_grid_unifier(A,B,AA),!.
min_unifier_u(A,B,AA):- is_list(A),is_list(B),!,min_list_unifier(A,B,AA),
ignore((length(A,AL),length(B,AL),length(AA,AL))).
min_unifier(A,B,AA):- is_cons(A),is_cons(B),!,min_list_unifier(A,B,AA),!.
min_unifier_u(A,B,AA):- is_cons(A),is_cons(B),!,min_list_unifier(A,B,AA),!.
%min_unifier(A,B,C):- is_list(A),sort_safe(A,AA),A\==AA,!,min_unifier(B,AA,C).
min_unifier(A,B,R):- compound(A),compound(B),
min_unifier_u(A,B,R):- compound(A),compound(B),
compound_name_arguments(A,F,AA),compound_name_arguments(B,F,BB),!,
my_maplist(must_min_unifier,AA,BB,RR),compound_name_arguments(R,F,RR).
min_unifier(A,B,R):- relax_hint(A,R),\+ (B \= R),!.
min_unifier(A,B,_):- (\+ compound(A);\+ compound(B)),!.
my_maplist(min_unifier,AA,BB,RR),compound_name_arguments(R,F,RR).
min_unifier_u(A,B,R):- relax_hint(A,R),\+ (B \= R),!.

is_cons(A):- compound(A),A=[_|_].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@
%length(Group1,G1), length(Group2,G2), G1>G2,
once((sub_term(E,How1),sub_var(E,How2))),
%member(M1,Group1),member(M2,Group2),M1=M2,
my_append(Group1,Group2,GroupJ), sort_safe(GroupJ,Group),
append(Group1,Group2,GroupJ), sort_safe(GroupJ,Group),
How = [How1,How2]))
*-> true ; is_why_grouped(TestID,_,How,Group).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
%free_cell(8).

%trim_unused_vert_square(BG,Grid,GridO).
%trim_unused_vert_square(BG,GridR,GridO):- my_append(Grid,[Row],GridR),my_maplist(is_bg_or_var(BG),Row),trim_unused_vert_square(BG,Grid,GridO).
%trim_unused_vert_square(BG,GridR,GridO):- append(Grid,[Row],GridR),my_maplist(is_bg_or_var(BG),Row),trim_unused_vert_square(BG,Grid,GridO).
%trim_unused_vert_square(_,G,G).*/

non_h_rot(sameR).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
combine_grids(How,H,G,GM),
combine_grids(How,T,GM,GO).
combine_grids(overlay,H,G,GM):- globalpoints(H,Points),set_local_points(Points,G,GM),!.
combine_grids(my_append,H,G,GM):- grid_size(H,W,_),length(Row,W), my_append(G,[Row|H],GM).
combine_grids(append,H,G,GM):- grid_size(H,W,_),length(Row,W), append(G,[Row|H],GM).

print_info:- test_config(noprint_info),!,fail.
print_info:- test_config(print_info),!.
Expand Down
14 changes: 7 additions & 7 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_imageproc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
%term_singletons(Cs,Ss),include(is_colorish,Ss,CC),!.

pixel_colors1(GH,CC):- is_grid(GH),!,mapgrid(only_color_data_or(wbg),GH,Cs),append(Cs,CC).
pixel_colors1(GH,CC):- is_list(GH),!,my_maplist(pixel_colors0,GH,PG),my_append(PG,CC).
pixel_colors1(GH,CC):- is_list(GH),!,my_maplist(pixel_colors0,GH,PG),append(PG,CC).
pixel_colors1(GH,CC):- is_colorish(GH),!,CC=GH.
pixel_colors1(Cell,[C]):- is_point(Cell),!,only_color_data_or(fg,Cell,C).
pixel_colors1(GH,CC):- globalpoints_include_bg(GH,GP),!,my_maplist(only_color_data_or(fg),GP,CC).
Expand Down Expand Up @@ -169,27 +169,27 @@
% grow([[sameR,sameR]],[[a,b,c]], [[a,b,c,a,b,c]]).
hconcat(Grid1,[],Grid1):-!.
hconcat(Grid1,Empty,Grid1):- is_empty_grid(Empty),!.
hconcat(Grid1,Grid2,Grid):- length(Grid1,Len),assertion(length(Grid2,Len)),my_maplist(my_append,Grid1,Grid2,Grid).
hconcat(Grid1,Grid2,Grid):- length(Grid1,Len),assertion(length(Grid2,Len)),my_maplist(append,Grid1,Grid2,Grid).

vconcat(Grid1,Grid2,Grid):- my_append(Grid1,Grid2,Grid).
vconcat(Grid1,Grid2,Grid):- append(Grid1,Grid2,Grid).

p2_grow_row([],_,[]).
p2_grow_row([C1|Row],Grid,GM):- !, call(C1,Grid,G1),p2_grow_row(Row,Grid,GR),hconcat(G1,GR,GM).
p2_grow([], _ ,[]).
p2_grow([Row|Rows],Grid,G1GridO):- p2_grow_row(Row,Grid,G1), p2_grow(Rows,Grid,GridO),my_append(G1,GridO,G1GridO).
p2_grow([Row|Rows],Grid,G1GridO):- p2_grow_row(Row,Grid,G1), p2_grow(Rows,Grid,GridO),append(G1,GridO,G1GridO).

p1_grow_row([],_,[]).
p1_grow_row([C1|Row],Grid,GM):- !, call(C1,G1),p1_grow_row(Row,Grid,GR),hconcat(G1,GR,GM).
p1_grow([], _ ,[]).
p1_grow([Row|Rows],Grid,G1GridO):- p1_grow_row(Row,Grid,G1), p1_grow(Rows,Grid,GridO),my_append(G1,GridO,G1GridO).
p1_grow([Row|Rows],Grid,G1GridO):- p1_grow_row(Row,Grid,G1), p1_grow(Rows,Grid,GridO),append(G1,GridO,G1GridO).


copy_grid_based_on_color(Cell,G,G1):- \+ is_fg_color(Cell),!,grid_size(G,H,V),make_grid(H,V,G1), mapgrid(=(Cell),G1).
copy_grid_based_on_color(_,G,G1):- safe_grid(G,G1).
grow_row([],_,[]).
grow_row([C1|Row],Grid,GM):- !, copy_grid_based_on_color(C1,Grid,G1),grow_row(Row,Grid,GR),hconcat(G1,GR,GM).
grow([], _ ,[]).
grow([Row|Rows],Grid,G1GridO):- grow_row(Row,Grid,G1), grow(Rows,Grid,GridO),my_append(G1,GridO,G1GridO).
grow([Row|Rows],Grid,G1GridO):- grow_row(Row,Grid,G1), grow(Rows,Grid,GridO),append(G1,GridO,G1GridO).

grow_from_shape(I,O):- max_fg_color(I,Max),mapgrid(only_this_color_or_p1(Max,var),I,Pattern),grow_from_shape(Pattern,I,O).
grow_from_shape(Grid,I,O):- grow(Grid,I,O).
Expand Down Expand Up @@ -722,7 +722,7 @@

replace_col(N,Col,Grid,_,V,NewGrid):- Nm1 is N - 1, length(Col,V),my_maplist(replace_col_at_0(Nm1),Col,Grid,NewGrid).

replace_col_at_0(N,Col,Row,NewRow):- length(Left,N),my_append(Left,[_|Right],Row),my_append(Left,[Col|Right],NewRow).
replace_col_at_0(N,Col,Row,NewRow):- length(Left,N),append(Left,[_|Right],Row),append(Left,[Col|Right],NewRow).


get_surround_3x3(Grid,H,V,Result):-
Expand Down
Loading

0 comments on commit 6f88104

Please sign in to comment.