switch_player is a Python function for changing turns in the Bogart dice game. It returns the other player's number when the game continues, but preserves the current player's number when the game has ended. section 10.4.2
The function separates turn-switching from the rest of the game's control logic:
- Accepts player 1's chips, player 2's chips, the latest dice rolls, and the current player number. section 10.4.2
- Changes 1 to 2 or 2 to 1, then returns the resulting current-player number. section 10.4.2
Turn at the end of a game
If current_player is 1 and game_over(player1, player2, rolls) is false, switch_player returns 2. If the game is over, it returns 1 instead.
