Added almost all the game core logic.
minor modification to index.html