Other answers discuss how to decide the correct direction to move in in different circumstances. You can also add a lag time before the computer player "reacts" by starting to move in this direction -- that mirrors the typical response of human players.