logic for Reversi