function KB_out = BR_gen_Wumpus_Gold(KB)
% BR_gen_Wumpus_Gold - generate Wumpus/Gold location logic in KB
% On input:
%     KB (CNF KB): knowledge base
% On output:
%     KB_out (CNF KB): KB with Wumpus location logic
% Call:
%     KB = BR_gen_Wumpus_locs([]);
% Author:
%     T. Henderson
%     UU
%     Summer 2017
%

BLANK = ' ';
KB_out = KB;
num_clauses = length(KB);

lin_indexes = [...
    1,1;2,1;3,1;4,1;...
    1,2;2,2;3,2;4,2;...
    1,3;2,3;3,3;4,3;...
    1,4;2,4;3,4;4,4];

nei_clause = [];
for w1 = 1:15
    x1 = lin_indexes(w1,1);
    y1 = lin_indexes(w1,2);
    if isempty(nei_clause)
        nei_clause = ['W',num2str(x1),num2str(y1)];
    else
        nei_clause = [nei_clause,BLANK,'W',num2str(x1),...
            num2str(y1)];
    end
    for w2 = w1+1:16
        x2 = lin_indexes(w2,1);
        y2 = lin_indexes(w2,2);
            if (x1~=x2|y1~=y2)%&~(x1==1&y1==1)&~(x2==1&y2==1)
                num_clauses = num_clauses + 1;
                KB_out(num_clauses).clauses = ...
                    ['-W',num2str(x1),num2str(y1),BLANK,...
                        '-W',num2str(x2),num2str(y2)];
                    num_clauses = num_clauses + 1;
                    KB_out(num_clauses).clauses = ...
                        ['-G',num2str(x1),num2str(y1),BLANK,...
                        '-G',num2str(x2),num2str(y2)];
            end
    end
end
