function direction = myAI2(game)

for i=2:3
    for j=2:3     
        
        if game.Board(i,j)==game.Board(i-1,j-1)
             if sumn(game,1:i-1,j-1)==sumn(game,1:i,j)
                 move(game,'up');
                 move(game,'left');
                 direction=myAI1(game);
                 return;
             else if sumn(game,i-1:4,j-1)==sumn(game,i:4,j)
                 move(game,'down');
                 move(game,'left');
                 direction=myAI1(game);
                 return;
                 else if sumn(game,i-1,1:j-1)==sumn(game,i,1:j)
                 move(game,'left');
                 move(game,'up');
                 direction=myAI1(game);
                 return;
                     else if sumn(game,i-1,j-1:4)==sumn(game,i,j:4)
                 move(game,'right');
                 move(game,'up');
                 direction=myAI1(game);
                 return;
                          end                 
                     end
                 end
             end
        end
        
        if game.Board(i,j)==game.Board(i-1,j+1) 
            if sumn(game,1:i-1,j+1)==sumn(game,1:i,j)
                 move(game,'up');
                 move(game,'right');
                 direction=myAI1(game);
                 return;
             else if sumn(game,i-1:4,j+1)==sumn(game,i:4,j)
                 move(game,'down');
                 move(game,'right');
                 direction=myAI1(game);
                 return;
                 else if sumn(game,i-1,1:j+1)==sumn(game,i,1:j)
                 move(game,'left');
                 move(game,'up');
                 direction=myAI1(game);
                 return;
                     else if sumn(game,i-1,j+1:4)==sumn(game,i,j:4)
                 move(game,'right');
                 move(game,'up');
                 direction=myAI1(game);
                 return;
                          end                 
                     end
                 end
             end
        end
        
        if game.Board(i,j)==game.Board(i+1,j-1) 
             if sumn(game,1:i+1,j-1)==sumn(game,1:i,j)
                 move(game,'up');
                 move(game,'left');
                 direction=myAI1(game);
                 return;
             else if sumn(game,i+1:4,j-1)==sumn(game,i:4,j)
                 move(game,'down');
                 move(game,'left');
                 direction=myAI1(game);
                 return;
                 else if sumn(game,i+1,1:j-1)==sumn(game,i,1:j)
                 move(game,'left');
                 move(game,'down');
                 direction=myAI1(game);
                 return;
                     else if sumn(game,i+1,j-1:4)==sumn(game,i,j:4)
                 move(game,'right');
                 move(game,'down');
                 direction=myAI1(game);
                 return;
                          end                 
                     end
                 end
             end
        end
        
        if game.Board(i,j)==game.Board(i+1,j+1)
             if sumn(game,1:i-1,j-1)==sumn(game,1:i,j)
                 move(game,'up');
                 move(game,'right');
                 direction=myAI1(game);
                 return;
             else if sumn(game,i-1:4,j-1)==sumn(game,i:4,j)
                 move(game,'down');
                 move(game,'right');
                 direction=myAI1(game);
                 return;
                 else if sumn(game,i-1,1:j-1)==sumn(game,i,1:j)
                 move(game,'left');
                 move(game,'down');
                 direction=myAI1(game);
                 return;
                     else if sumn(game,i-1,j-1:4)==sumn(game,i,j:4)
                 move(game,'right');
                 move(game,'down');
                 direction=myAI1(game);
                 return;
                          end                 
                     end
                 end
             end
        end
        
    end
end

direction=myAI1(game);

