image thumbnail
from Opti Move by Krishna Lalith
Famous game called "FULL BOARD" by Erich Friedman.

Opti_Move(action)
function Opti_Move(action)

global Level Lnum lengthy score;
clc
%--------------------------------------------------------------------------
if nargin < 1, Lnum=1; action = 'initialize'; end;
%--------------------------------------------------------------------------
if strcmp(action,'initialize')
    for ii=1:20
        Level(ii).Box=zeros(5+floor(ii/9),5+floor(ii/9));
    end
 %defining obstucles   
    Level(1).Box(1,5)=1; Level(1).Box(4,4)=1;
    Level(2).Box(2,4)=1; Level(2).Box(3,5)=1;
    Level(3).Box(2,4)=1; Level(3).Box(3,5)=1; Level(3).Box(4,3)=1;
    Level(4).Box(2,4)=1; Level(4).Box(3,1)=1; Level(4).Box(4,5)=1;
    Level(5).Box(1,5)=1; Level(5).Box(4,2)=1; Level(5).Box(4,3)=1;
    Level(6).Box(1,5)=1; Level(6).Box(3,4)=1; Level(6).Box(5,1)=1;    
    Level(7).Box(1,5)=1; Level(7).Box(2,5)=1; Level(7).Box(3,2)=1; Level(7).Box(5,3)=1;
    Level(8).Box(1,5)=1; Level(8).Box(3,4)=1; Level(8).Box(4,1)=1; Level(8).Box(5,3)=1;
    Level(9).Box(1,5)=1; Level(9).Box(1,3)=1; Level(9).Box(1,4)=1; Level(9).Box(5,1)=1; Level(9).Box(5,2)=1;
    Level(10).Box(3,3)=1; Level(10).Box(3,6)=1;
    Level(11).Box(2,5)=1; Level(11).Box(6,3)=1;
    Level(12).Box(3,5)=1; Level(12).Box(3,6)=1; Level(12).Box(5,2)=1;
    Level(13).Box(1,1)=1; Level(13).Box(1,6)=1; Level(13).Box(3,5)=1; Level(13).Box(4,3)=1;
    Level(14).Box(2,5)=1; Level(14).Box(3,3)=1; Level(14).Box(5,2)=1; Level(14).Box(5,5)=1;
    Level(15).Box(1,1)=1; Level(15).Box(1,6)=1; Level(15).Box(2,4)=1; Level(15).Box(5,2)=1; Level(15).Box(6,4)=1;
    Level(16).Box(2,5)=1; Level(16).Box(3,1)=1; Level(16).Box(3,5)=1; Level(16).Box(5,3)=1; Level(16).Box(5,4)=1; Level(16).Box(6,1)=1;
    Level(17).Box(1,1)=1; Level(17).Box(3,2)=1; Level(17).Box(4,2)=1; Level(17).Box(6,1)=1; Level(17).Box(6,5)=1; Level(17).Box(6,6)=1;
    Level(18).Box(3,3)=1; Level(18).Box(3,5)=1; Level(18).Box(4,5)=1; Level(18).Box(5,2)=1; Level(18).Box(6,6)=1;
    Level(19).Box(1,6)=1; Level(19).Box(1,7)=1; Level(19).Box(2,4)=1; Level(19).Box(3,2)=1; Level(19).Box(4,4)=1;
    Level(20).Box(4,6)=1; Level(20).Box(5,2)=1; Level(20).Box(5,3)=1; Level(20).Box(6,3)=1; Level(20).Box(7,1)=1;
%--------------------------------------------------------------------------   
    fig=figure( ...
                'Name','Opti Move', 'NumberTitle','off', ...
                'Visible','off', 'BackingStore','off');   

    lengthy=5+floor((Lnum-1)/9);
    score=1;
    Level(Lnum).Connect=[];
    Handle_Set(Lnum,Level);
    figure(fig);
end
%--------------------------------------------------------------------------
if strcmp(action,'Up') 
    Lnum=Lnum+1;
    if Lnum>20,  Lnum=1;  end
    %Handle_Set(Lnum,Level);
    clf
    closereq;
    Opti_Move('initialize');
end
%--------------------------------------------------------------------------
if strcmp(action,'Down')    
    Lnum=Lnum-1;
    if Lnum<1,  Lnum=20;  end
    %Handle_Set(Lnum,Level);
    clf
    closereq
    Opti_Move('initialize');
end
%--------------------------------------------------------------------------
if strcmp(action,'Play') 
    %Start Point
    valid=0;
    while (valid==0)
        [Xnew Ynew Button] = ginput(1);        
        if Button~=1,  return;  end        
        if (Button==1),
            Xnew=floor(Xnew);
            Ynew=floor(Ynew);
            if(Xnew>0 & Xnew<lengthy+1 & Ynew>0 & Ynew<lengthy+1),  
                valid=1;
            end
            
            for ii=1:lengthy
                for jj=1:lengthy
                    if Level(Lnum).Box(ii,jj)==1, 
                       if (ii==Xnew && jj==Ynew),  valid=0;  end
                    end
                end
            end
            
            if(valid==1),
                Level(Lnum).Box(Xnew,Ynew)=2;
                Level(Lnum).Connect(score,:)=[Xnew Ynew];
                score=score+1;
                Handle_Set(Lnum,Level);
            end            
        end
    end

 finish=0;
 while finish==0,   
    %Direction Point
    valid=0;
    while (valid==0)
        [DXnew DYnew Button] = ginput(1);        
        if Button~=1, return;  end        
    
        if Button==1,
            DXnew=floor(DXnew);
            DYnew=floor(DYnew);
            if(DXnew>0 & DXnew<lengthy+1 & DYnew>0 & DYnew<lengthy+1),
                if xor(Xnew==DXnew,Ynew==DYnew), valid=1;  end
            end
            
            for ii=1:lengthy
                for jj=1:lengthy
                    if Level(Lnum).Box(ii,jj)==1, 
                       if (ii==DXnew && jj==DYnew),  valid=0;  end
                    end
                end
            end            
        end 
    end

    if valid==1,
       %Up n Down
       if DXnew==Xnew,
           if DYnew<Ynew
                for ii=Ynew-1:-1:1
                    if (Level(Lnum).Box(DXnew,ii)==1 || Level(Lnum).Box(DXnew,ii)==2), break; end
                    Level(Lnum).Box(DXnew,ii)=2;
                    Level(Lnum).Connect(score,:)=[Xnew ii];
                    score=score+1;
                    CheckPoint=[DXnew ii];
                end
           end
           if DYnew>Ynew
                for ii=Ynew+1:1:lengthy
                    if (Level(Lnum).Box(DXnew,ii)==1 || Level(Lnum).Box(DXnew,ii)==2), break; end
                    Level(Lnum).Box(DXnew,ii)=2;
                    Level(Lnum).Connect(score,:)=[Xnew ii];
                    score=score+1;
                    CheckPoint=[DXnew ii];
                end
           end
       end
       
       %Right n Left
       if DYnew==Ynew,
           if DXnew<Xnew
                for ii=Xnew-1:-1:1
                    if (Level(Lnum).Box(ii,DYnew)==1 || Level(Lnum).Box(ii,DYnew)==2), break; end
                    Level(Lnum).Box(ii,DYnew)=2;
                    Level(Lnum).Connect(score,:)=[ii Ynew];
                    score=score+1;
                    CheckPoint=[ii DYnew];
                end
           end
           if DXnew>Xnew
                for ii=Xnew+1:1:lengthy
                    if (Level(Lnum).Box(ii,DYnew)==1 || Level(Lnum).Box(ii,DYnew)==2), break; end
                    Level(Lnum).Box(ii,DYnew)=2;
                    Level(Lnum).Connect(score,:)=[ii Ynew];
                    score=score+1;
                    CheckPoint=[ii DYnew];
                end
           end
       end
       
       Handle_Set(Lnum,Level);       
    end    
    
    Xnew=CheckPoint(1,1);
    Ynew=CheckPoint(1,2);
    finish=Check_Constraint(Lnum,Level,CheckPoint);    
      
    if finish==1,
        if isempty(find(Level(Lnum).Box==0,1))==0,
            msg=['No move...U LOST the Game...'];
            [jerrydata jerrymap]=imread('jerry.jpg');
            msg_handle=msgbox(msg,'Good Try...!','custom',jerrydata,jerrymap);        
            return
        end

        if isempty(find(Level(Lnum).Box==0,1))==1,
            msg=['Congrats...U WON the Game...'];
            [namastedata namastemap]=imread('namaste.jpg');
            msg_handle=msgbox(msg,'Nice Play...!','custom',namastedata,namastemap);        
            %return 
            pause(4);
            Opti_Move('Up'); 
        end
    end
            
  end
end
%--------------------------------------------------------------------------
if strcmp(action,'Restart') 
    clf
    closereq
    Opti_Move('initialize');    
end
%--------------------------------------------------------------------------
if strcmp(action,'Solution')
    clf
    %obviously only path
   switch Lnum
       case 1
           Level(1).Connect=[1 4;1 1;5 1;5 5;2 5;2 2;4 2;4 3;3 3;3 4];
       case 2
           Level(2).Connect=[2 5;1 5;1 1;5 1;5 5;4 5;4 2;2 2;2 3;3 3;3 4];  
       case 3
           Level(3).Connect=[4 2;1 2;1 1;5 1;5 5;4 5;4 4;3 4;3 3;1 3;1 5;2 5];    
       case 4
           Level(4).Connect=[5 5;5 1;4 1;4 4;3 4;3 5;1 5;1 1;2 1;2 3;3 3;3 2];
       case 5
           Level(5).Connect=[1 4;1 1;5 1;5 5;2 5;2 2;3 2;3 4;4 4];
       case 6
           Level(6).Connect=[4 1;1 1;1 4;2 4;2 5;5 5;5 2;2 2;2 3;4 3;4 4];
       case 7
           Level(7).Connect=[3 5;5 5;5 4;1 4;1 1;5 1;5 2;4 2;4 3;2 3;2 2];
       case 8
           Level(8).Connect=[2 2;1 2;1 1;3 1;3 3;1 3;1 4;2 4;2 5;5 5;5 4;4 4;4 2;5 2;5 2;5 1];
       case 9
           Level(9).Connect=[3 2;4 2;4 1;1 1;1 2;2 2;2 5;5 5;5 3;3 3;3 4;4 4];
       case 10
           Level(10).Connect=[4 6;6 6;6 1;1 1;1 6;2 6;2 2;5 2;5 5;3 5;3 4;4 4;4 3]; 
       case 11
           Level(11).Connect=[2 4;2 1;1 1;1 6;6 6;6 1;3 1;3 5;5 5;5 4;4 4;4 2;5 2;5 3];
       case 12
           Level(12).Connect=[5 5;5 3;1 3;1 6;2 6;2 4;4 4;4 6;6 6;6 1;1 1;1 2;4 2]; 
       case 13
           Level(13).Connect=[2 3;3 3;3 1;2 1;2 2;1 2;1 5;2 5;2 6;6 6;6 1;4 1;4 2;5 2;5 5;4 5;4 4;3 4;2 4];  
       case 14
           Level(14).Connect=[4 5;4 6;6 6;6 1;1 1;1 6;3 6;3 4;5 4;5 3;4 3;4 2;2 2;2 4];
       case 15
           Level(15).Connect=[3 2;4 2;4 6;6 6;6 5;5 5;5 3;6 3;6 1;2 1;2 3;3 3;3 6;2 6;2 5;1 5;1 2];
       case 16
           Level(16).Connect=[5 5;4 5;4 1;5 1;5 2;6 2;6 6;1 6;1 1;2 1;2 4;3 4;3 2];
       case 17
           Level(17).Connect=[5 3;1 3;1 2;2 2;2 1;5 1;5 2;6 2;6 4;1 4;1 6;5 6;5 5;2 5];
       case 18
           Level(18).Connect=[3 4;7 4;7 1;1 1;1 7;7 7;7 5;5 5;5 6;2 6;2 2;4 2;4 3;6 3;6 2];
       case 19
           Level(19).Connect=[2 5;1 5;1 1;7 1;7 7;2 7;2 6;6 6;6 2;4 2;4 3;5 3;5 5;3 5;3 3;2 3;2 2];
       case 20
           Level(20).Connect=[3 3;4 3;4 1;6 1;6 2;7 2;7 7;1 7;1 1;3 1;3 2;2 2;2 6;3 6;3 4;6 4;6 6;5 6;5 5;4 5];    
   end
   
   Level(Lnum).Box(Level(Lnum).Connect(1,1),Level(Lnum).Connect(1,2))=3;
   for ii=2:size(Level(Lnum).Connect,1)-1
       Level(Lnum).Box(Level(Lnum).Connect(ii,1),Level(Lnum).Connect(ii,2))=2;
   end
   Level(Lnum).Box(Level(Lnum).Connect(size(Level(Lnum).Connect,1),1),Level(Lnum).Connect(size(Level(Lnum).Connect,1),2))=4;

   Handle_Set(Lnum,Level);
end
%--------------------------------------------------------------------------
if strcmp(action,'Help')
    msg=['DESCRIPTION:                                                                                 ';...
         '-->Original idea by "Erich Friedman" with game name as "FULL HOUSE".                         ';...
         '                                                                                             ';...
         '--> Select the level using "Level Up" & "Level Down".                                        ';...
         '--> Click on "Play" button to start the game.                                                ';...
         '--> Click on the box to mark your start position.                                            ';...
         '--> Click on the other box to mark your direction.                                           ';...
         '--> Draw a path moving horizontally or vertically that passes through each open square.      ';...
         '--> The blue runner will always run straight, as far as possible, stopping only when blocked.';...
         '                                                                                             ';...
         '--> Click Solution to view the solution (Green Ball : Start; Red Ball : End).                '];
     
    msg_handle=msgbox(msg,'GAME->Optimum Move','help');
end
%--------------------------------------------------------------------------

Contact us at files@mathworks.com