7th Guest Germ Game

by

 

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

[A,test,c]=guestzetdoen(A,x1,y1,x2,y2,check,method)
function [A,test,c]=guestzetdoen(A,x1,y1,x2,y2,check,method)

if strcmp(check,'turn')
    load('C:\My Documents\MATLAB\infection\colors.mat');
end

test=0;
if ~(x1==x2 && y1==y2) && A(x1,y1)~=0 && A(x2,y2)==0  % en coordinaten liggen in t veld
    if abs(x1-x2)<=2 && abs(y1-y2)<=2 % coordinaten liggen binnen 5x5 vak
        if abs(x1-x2)<=1 && abs(y1-y2)<=1    %naastliggend
            A(x2,y2)=A(x1,y1);
        else                                 %niet naastliggend
            A(x2,y2)=A(x1,y1);
            A(x1,y1)=0;
        end
    else
        return
    end
    
    if strcmp(check,'turn')
        makeboard(A)
        if A(x2,y2)==1
            wavplay(bluesound,44100); 
% %             p = audioplayer(bluesound,44100); 
% %             play(p);
        else
            wavplay(greensound,44100); 
% %             p = audioplayer(greensound,44100); 
% %             play(p);
        end
    end
    
    
    a1=x2-1;if a1<1;a1=1;end
    a2=x2+1;if a2>7;a2=7;end
    b1=y2-1;if b1<1;b1=1;end
    b2=y2+1;if b2>7;b2=7;end
    
    if strcmp(method,'manual')
        c=length(find(A(a1:a2,b1:b2)==(A(x2,y2)*-1)));
    else
        c=0;
    end
    
    
    for m=a1:a2
        for n=b1:b2
            if A(m,n)==(A(x2,y2)*-1)
                A(m,n)=A(x2,y2);

                if strcmp(check,'turn')
                    makeboard(A)
                    if A(x2,y2)==1
                        wavplay(bluesound,44100);
                        % %             p = audioplayer(bluesound,44100);
                        % %             play(p);
                    else
                        wavplay(greensound,44100);
                        % %             p = audioplayer(greensound,44100);
                        % %             play(p);
                    end
                end
                
            end
        end
    end
end

test=1;

Contact us