One little thing...
Math.sqrt() is fairly processor-heavy. However, you do not have to square-root the hypotenuse (longest side) to compare distances, because if length A is greater than length B, A^2 will always be bigger than B^2.
EDIT: Also, if you do get it to learn from mistakes, and the IO library is solved, you could have your AI store its knowledge elsewhere, and learn more and more every match it plays. Though I think that may be a little hard.