Simple AI Game on JavaScript