function direction = myAI1(game)

ud_count=0;
lr_count=0;

for i=1:4
    for j=1:4
        
        if j<4&&game.Board(i,j)==game.Board(i,j+1) 
            lr_count=lr_count+1;
        end
        if i<4&&game.Board(i,j)==game.Board(i+1,j) 
            ud_count=ud_count+1;
        end
        
        if game.Board(1,j)==game.Board(3,j)&&isnan(game.Board(2,j))
            ud_count=ud_count+1;
        end
        if game.Board(1,j)==game.Board(4,j)&&isnan(game.Board(2,j))&&isnan(game.Board(3,j))
            ud_count=ud_count+1;
        end
        if game.Board(2,j)==game.Board(4,j)&&isnan(game.Board(3,j))
            ud_count=ud_count+1;
        end
    end
    
    if game.Board(i,1)==game.Board(i,3)&&isnan(game.Board(i,2))
        lr_count=lr_count+1;
    end
    if game.Board(i,1)==game.Board(i,4)&&isnan(game.Board(i,2))&&isnan(game.Board(i,3))
        lr_count=lr_count+1;
    end
    if game.Board(i,2)==game.Board(i,4)&&isnan(game.Board(i,3))
        lr_count=lr_count+1;
    end
    
end

if lr_count>ud_count
    prob=[0.1 0.2 0.6];
else
    prob=[0.4 0.8 0.9];
end

p=rand();

if p<prob(1)
    direction='up';
else if p>=prob(1)&&p<prob(2)
        direction='down';
    else if p>=prob(2)&&p<prob(3)
            direction='left';
        else
            direction='right';
        end
    end
end