So my teacher give me an assigment that to me seems out of this worls or at least of my class, and well maybe is bacause we barely had practice with prolog, what I have to do is write a prolog program that solves the game Blobs from the page “mindgames”, I think I could do this on python or C++ cause I’m familiar with this codes, but I’m not at all familiar with prolog, I’m struggling a lot. This is what I think I should do:

- Have a function to tells me what has been painted and what not.
- Recursively search all the possible paths of known neighborgs that I should paint.
- Make a restriction of moves. Save the choosen color (or the move) in a list that I should print as an answer.

Lately what I did was search on the web on how to make list, and how to use matrix and actually trying to understand how it works. But prolog is not documented in a way that is easy to understand for me. My teacher said that I should separate the problem like this:

- Expand your search and mark eveyone that have the same color at the beggining.
- Paint the neighborgs that you can.
- Save this on a list to print
- Do it recursively

From internet I got the way to find nighborgs, and how to index a list into a matrix, but thats all, I don’t think I’m understanding how prolog works to do this.

What I have, and I don’t know if this would work for my problem

:- use_module(library(clpfd)).

% at, permite indexar la matriz

at(Mat, [Row, Col], Val) :- nth1(Row, Mat, ARow), nth1(Col, ARow, Val).% indices, generador de indices de la matriz

add(X,L,Ls) :- Ls = [X|[L]].

indices1(L,X,Ls) :- maplist(add(X),L,Ls).

indices2(L1,L2,Li) :- maplist(indices1(L2),L1,Ls), append(Ls,Li).

indices(M,N,Is) :- numlist(1,M,LMs), numlist(1,N,LNs), indices2(LMs,LNs,Is).% vecino, posiciones vecinas de [X,Y]

vecino([X,Y],[X,Y1]) :- Y1 #= Y+1.

vecino([X,Y],[X,Y1]) :- Y1 #= Y-1.

vecino([X,Y],[X1,Y]) :- X1 #= X+1.

vecino([X,Y],[X1,Y]) :- X1 #= X-1.

Thanks in advance.