pub fn update_scores(&mut self, player: Cell) {
        let winner = self.trial_board.check_win();
        let score_player = 2;
        let score_other = 1;
        if winner == Cell::PLAYER1 || winner == Cell::PLAYER2 {
            let other = match player {
                Cell::PLAYER1 => Cell::PLAYER2,
                _ => Cell::PLAYER1,
            };
            //log("yeah5".to_string());
            for (row_ind, rows) in self.scores.iter_mut().enumerate() {
                //log(format!("scores {:?}", rows));
                for (cell_ind, cell) in rows.iter_mut().enumerate() {
                    if self.trial_board.get_cell(row_ind, cell_ind) == player {
                        if player == winner {
                            *cell = *cell + score_player;
                        } else {
                            *cell = *cell - score_player;
                        }
                    } else if self.trial_board.get_cell(row_ind, cell_ind) == other {
                        if player == winner {
                            *cell = *cell - score_other;
                        } else {
                            *cell = *cell + score_other;
                        }
                    }
                }
            }
        }
    }
/*Put a weigth on each cell according to the result of the trial
     if the currentPlayer win the trial then all the cells where you have 'ENUM::CURRENTPLAYER' is incremented
     orthewise decremented
     this code is called trial_num times aka 1000 times!!
     this is necessary to make the ai unbeatable
    */
Put a weigth on each cell according to the result of the trial
if the currentPlayer win the trial then all the cells where you have 'ENUM::CURRENTPLAYER' is incremented
orthewise decremented
this code is called trial_num times aka 1000 times
this is necessary to make the ai unbeatable
Put a weigth on each cell according to the result of the trial if the currentPlayer win the trial then all the cells where you have ' ENUM :: CURRENTPLAYER ' is incremented orthewise decremented this code is called trial_num times aka 1000 times this is necessary to make the ai unbeatable
pub fn update_scores(&mut self, player: Cell) {
        let winner = self.trial_board.check_win();
        let score_player = 2;
        let score_other = 1;
        if winner == Cell::PLAYER1 || winner == Cell::PLAYER2 {
            let other = match player {
                Cell::PLAYER1 => Cell::PLAYER2,
                _ => Cell::PLAYER1,
            };
            //log("yeah5".to_string());
            for (row_ind, rows) in self.scores.iter_mut().enumerate() {
                //log(format!("scores {:?}", rows));
                for (cell_ind, cell) in rows.iter_mut().enumerate() {
                    if self.trial_board.get_cell(row_ind, cell_ind) == player {
                        if player == winner {
                            *cell = *cell + score_player;
                        } else {
                            *cell = *cell - score_player;
                        }
                    } else if self.trial_board.get_cell(row_ind, cell_ind) == other {
                        if player == winner {
                            *cell = *cell - score_other;
                        } else {
                            *cell = *cell + score_other;
                        }
                    }
                }
            }
        }
    }
pub fn update_scores ( & mut self , player : Cell ) { let winner = self . trial_board . check_win ( ) ; let score_player = 2 ; let score_other = 1 ; if winner == Cell :: PLAYER1 || winner == Cell :: PLAYER2 { let other = match player { Cell :: PLAYER1 => Cell :: PLAYER2 , _ => Cell :: PLAYER1 , } ; //log("yeah5".to_string()); for ( row_ind , rows ) in self . scores . iter_mut ( ) . enumerate ( ) { //log(format!("scores {:?}", rows)); for ( cell_ind , cell ) in rows . iter_mut ( ) . enumerate ( ) { if self . trial_board . get_cell ( row_ind , cell_ind ) == player { if player == winner { * cell = * cell + score_player ; } else { * cell = * cell - score_player ; } } else if self . trial_board . get_cell ( row_ind , cell_ind ) == other { if player == winner { * cell = * cell - score_other ; } else { * cell = * cell + score_other ; } } } } } }
Put a weigth on each cell according to the result of the trial
if the currentPlayer win the trial then all the cells where you have 'ENUM::CURRENTPLAYER' is incremented
orthewise decremented
this code is called trial_num times aka 1000 times!!
Put a weigth on each cell according to the result of the trial if the currentPlayer win the trial then all the cells where you have ' ENUM :: CURRENTPLAYER ' is incremented orthewise decremented this code is called trial_num times aka 1000 times!!
&mut self
player
Cell
&mut self
player
Cell