pub fn start(&mut self, game: Game) -> Result<Game, Problem> {
        let mut game = game;
        let mut result = Err(Problem::RightOutOfTheGate);
        while !game.finished() {
            let bowl_option = match game.turn() {
                Player::Red => self.red_strategy.play(&game.current),
                Player::Blue => self.blue_strategy.play(&game.current),
            };
            result = match bowl_option {
                Some(bowl) => game
                    .play(bowl)
                    .map_err(|foul_play| Problem::IllegalPlay(game.turn(), foul_play)),

                None => Err(Problem::NoPlay(game.turn())),
            };
            if result.is_err() {
                break;
            }
        }
        result.map(|_| game)
    }
/// Start the bout. Returns the result.
Start the bout. Returns the result.
Start the bout . Returns the result .
pub fn start(&mut self, game: Game) -> Result<Game, Problem> {
        let mut game = game;
        let mut result = Err(Problem::RightOutOfTheGate);
        while !game.finished() {
            let bowl_option = match game.turn() {
                Player::Red => self.red_strategy.play(&game.current),
                Player::Blue => self.blue_strategy.play(&game.current),
            };
            result = match bowl_option {
                Some(bowl) => game
                    .play(bowl)
                    .map_err(|foul_play| Problem::IllegalPlay(game.turn(), foul_play)),
                None => Err(Problem::NoPlay(game.turn())),
            };
            if result.is_err() {
                break;
            }
        }
        result.map(|_| game)
    }
pub fn start ( & mut self , game : Game ) -> Result < Game , Problem > { let mut game = game ; let mut result = Err ( Problem :: RightOutOfTheGate ) ; while ! game . finished ( ) { let bowl_option = match game . turn ( ) { Player :: Red => self . red_strategy . play ( & game . current ) , Player :: Blue => self . blue_strategy . play ( & game . current ) , } ; result = match bowl_option { Some ( bowl ) => game . play ( bowl ) . map_err ( | foul_play | Problem :: IllegalPlay ( game . turn ( ) , foul_play ) ) , None => Err ( Problem :: NoPlay ( game . turn ( ) ) ) , } ; if result . is_err ( ) { break ; } } result . map ( | _ | game ) }
Start the bout.
Start the bout .
&mut self
game
Game
&mut self
game
Game