views:

80

answers:

1

I have the following code which basically needs to add a list as an item to a greater list. So NewBoardsList should contain all the boards generated in the moves_generate_board function. The problem is that i get a False in Prolog. Any help ?

moves((Colour,_),Board,NewBoardsList):-
        other_colour(Colour,OtherColour),
        findall((X,Y,OtherColour,N),
            (member((X,Y,OtherColour,N),Board),
             threaten_by(Colour,(X,Y,OtherColour,N),Board)),
            Options),
        moves_generate_board(Options,Board,NewBoardsList).


    moves_generate_board([],Board,BoardsList).
    moves_generate_board([(X,Y,_,_)|T],Board,List):-
        replace((X,Y,-,-),Board,NewBoard),
        moves_generate_board(T,Board,[NewBoard|List]).
+2  A: 

I guess problem is in moves_generate_board/3 it looks very unusual. Maybe you wanted:

moves_generate_board([],_,[]). 
moves_generate_board([(X,Y,_,_)|T],Board,[NewBoard|List]):- 
  replace((X,Y,-,-),Board,NewBoard), 
  moves_generate_board(T,Board,List).

and about that replace((X,Y,-,-),... those - (dashes).... I'm not sure about what that means

ony