7th Guest Germ Game

by

 

The microscope game from 7th guest with simple 'AI'.

[moves]=availablemoves(A,turn)
function [moves]=availablemoves(A,turn)

moves=[];
count=1;
a=find(A==turn);
for i=1:length(a)
    x1=rem(a(i)-1,7)+1;
    y1=floor((a(i)-1)/7)+1;
    
    xmin=x1-2; if xmin<=0;xmin=1;end
    xmax=x1+2; if xmax>=8;xmax=7;end
    ymin=y1-2; if ymin<=0;ymin=1;end
    ymax=y1+2; if ymax>=8;ymax=7;end
    
    B=A(xmin:xmax,ymin:ymax);
    
    b=find(B==0);
    for j=1:length(b)
        x2=xmin-1+rem(b(j)-1,size(B,1))+1;
        y2=ymin-1+floor((b(j)-1)/size(B,1))+1;
        
        moves(count,1:4)=[x1,y1,x2,y2];
        count=count+1;
    end
end

Contact us