YJ- updated algorithm to not repeat the most recent move
YJ- minor changes
YJ- minor changes