Pedro Martínez: Ah indeed. In the procedure that I outlined below the legal moves are determined even before the user is asked to move. Although I didn't include it, the list of legal moves is necessary for the no-move-possible and dice-swapping logic.