I got the algorithm working, the next step will be deal with game status
I made a few improvements, mostly to the game javascript, the next step is improve game status feature, and add some automated tests.