%% Test %% **** %% ** %% is stable %% Assume a single region and a single line at each level. %% 1. Find x co-ordinates of the base %% 2. Find number of blocks on each side %% 3. Return whether the number of blocks on each side is the same %% test([[[0,1],'*'],[[1,1],'*'],[[2,1],'*'],[[3,1],'*'],[[0,0],' '],[[1,0],'*'],[[2,0],'*'],[[3,0],' ']],0,3,0,1). %%test(Map,XMin,XMax1,YMin,YMax) :- %% XMax2 is XMax1 + 1, %% findbase1(Map,XMin,XMax,0,Base1,Base2), findbase1(Map,XMin,XMax,0,Base1,Base2) :- findbase2(Map,XMin,XMax,0,[],Base), first(Base,Base1), last(Base,Base2). findbase2(_Pixels,X,X,_Y1,Base,Base). findbase2([Pixel|Pixels],X1,XMax,Y,Base1,Base2) :- Pixel = [Coords, '*'], Coords = [X1, Y], append(Base1,[X1],Base3), X2 is X1 + 1, findbase2(Pixels,X2,XMax,Y,Base3,Base2). findbase2([Pixel|Pixels],X1,XMax,Y,Base1,Base2) :- Pixel = [Coords, ' '], Coords = [X1, Y], X2 is X1 + 1, findbase2(Pixels,X2,XMax,Y,Base1,Base2). findbase2([Pixel|Pixels],X,XMax,Y1,Base1,Base2) :- Pixel = [Coords, _Symbol], Coords = [X, Y2], not(Y1=Y2), findbase2(Pixels,X,XMax,Y1,Base1,Base2). first([Base1|_Tail],Base1). last([Base2],Base2). last([_Head|Tail],Base2) :- last(Tail,Base2).