%% Breathesonings %% describes whether the person is happy or feeling normal %% objectdescription1([0,0,1,2,arc],[[0,0,1,2,arc,happy],[0,0,1,2,closed-arc,laughing]],Emotion) objectdescription1([X,Y,StartAngle,EndAngle,ArcType],ObjectDescriptions,Emotion) :- member([X,Y,StartAngle,EndAngle,ArcType,Emotion],ObjectDescriptions). %%objectdescription2([[1,0],[0,1],[1,1],[2,1],[1,2]],[[1,0,r],[0,1,r],[1,1,r],[2,1,r],[1,2,r],[0,0,n],[2,0,n],[0,2,n],[2,2,n]]). objectdescription2([],_ColouredCoords,_Colour). objectdescription2(Coords1,ColouredCoords1,Colour) :- Coords1=[Coord | Coords2], Coord=[X, Y], member(ColouredCoord,ColouredCoords1), delete(ColouredCoords1,ColouredCoord,ColouredCoords2), ColouredCoord=[X, Y, Colour], objectdescription2(Coords2,ColouredCoords2,Colour). %% Q: what would the porgram above do if member was not(member) and the program's result was negated? What is this program logically the same as? %% Breathesonings objection apple falls off stand %% leave([[0,1,0,vertical-line],[0,1,point]],[[[0,1,0,vertical-line],[0,1,point]],[[2,3,0,vertical-line],[2,3,point]]],Positive). %% leave([[Y1,Y2,X,vertical-line],[X,Y,point]],Shapes,Positive) leave(Shapes1,Shapes2,Positive) :- member(Shapes1,Shapes2), Positive=0,!. %% Counts red and white pixels, returning Positive=0 if there is at least one red pixel %%count([[1,0],[0,1],[1,1],[2,1],[1,2]],[[1,0,w],[0,1,w],[1,1,r],[2,1,w],[1,2,w],[0,0,w],[2,0,w],[0,2,w],[2,2,w]],Red,White,Positive). %%Red = 1, %%White = 4, %%Positive = 0 ; count(Coords1,ColouredCoords1,Red,White,Positive) :- count(Coords1,ColouredCoords1,0,Red,0,White), positive(Red,Positive). count([],_ColouredCoords,Red,Red,White,White). count(Coords1,ColouredCoords1,Red1,Red2,White1,White2) :- Coords1=[Coord | Coords2], Coord=[X, Y], member(ColouredCoord,ColouredCoords1), delete(ColouredCoords1,ColouredCoord,ColouredCoords2), ColouredCoord=[X, Y, Colour], count2(Colour,Red1,Red3,White1,White3), count(Coords2,ColouredCoords2,Red3,Red2,White3,White2). count2(r,Red1,Red2,White,White) :- Red2 is Red1 + 1. count2(w,Red,Red,White1,White2) :- White2 is White1 + 1. positive(Red,0) :- Red >= 1, !. positive(_Red,1).