Basic AI in Node.js/Socket.IO

I'm creating a small game in Node.js/Socket.IO and need some advice on creating the AI. The code I have below is a real quick example I came up with but it's so fast the player doesn't even see the enemy move on the client-side. Am I on the right lines with this approach or is there a better way I should be doing it?

Thanks!

var random;

setInterval(function() {
    random = Math.round(Math.random() * 200);
    move(random, random);
    console.log("Moving player");
}, 10000)

var move = function(targetX, targetY) {
    if (x < targetX) {
        while (x < targetX) {
            x++;
            sendNewCoordinates(x, y);
        }
    } else if (x > targetX) {
        while (x > targetX) {
            x--;
            sendNewCoordinates(x, y);
        }
    } else if (y < targetY) {
        while (y < targetX) {
            y++;
            sendNewCoordinates(x, y);
        }
    } else if (y > targetY) {
        while (y > targetX) {
            y--;
            sendNewCoordinates(x, y);
        }
    }
};

var sendNewCoordinates = function(newX, newY) {
    socket.sockets.emit("move enemy", {x: newX, y: newY});
};

That's actually a pretty good AI! Randomizing the interval between movements is a very easy, common technique for things like this. Im curious and would love to try whatever you are making! One thing to be aware of though, is to make sure the AI is not TOO good.

One other thing you could implement in your code is to have your AI "aim" for a point slightly away from the target. Eg:

var move = function(targetX + randomX, targetY + randomY)

You can also use the position of the target before it moved to predict where it is heading.

var xChange = (targetX2 - targetX1)/(timeInterval1);
var yChange = (targetY2 - targetY1)/(timeInterval1);
var move = function(targetX + xChange * timeInterval2, targetY + yChange * timeInterval2)

where timeInterval1 is the time interval between two of the targets positions and timeInterval2 is the time interval between your current position and your next position.

The key is not making the AI too hard for the player though. ;)