O ) ||
(state == OWIN amp; amp; _player.symbol == X )) {-INFINITY;
} else if (state == DRAW) {0;
}
} - 1;
} MiniMax (char _board [9], player _player) {best_val=-INFINITY, index=0; :: list lt; int gt; move_list; best_moves [9]={0}; _ moves (_board, move_list); (! move_list.empty ()) {
_ board [move_list.front ()]=_player.symbol;=_player.symbol; val=MinMove (_board, _player); (val gt; best_val) {_val=val;=0; _moves [index]=move_list.front () + 1;
} else if (val == best_val) {_moves [++ index]=move_list.front () + 1;
}
_ board [move_list.front ()]=0; _list.pop_front ();
} (index gt; 0) {= rand ()% index;
} best_moves [index];
} MinMove (char _board [9], player _player) {pos_value=evaluate_position (_board, _player); (pos_value!=- 1) {pos_value;
} best_val=+ INFINITY; :: list lt; int gt; move_list; _moves (_board, move_list); (! move_list.empty ()) {
_ player.symbol == X ? cSymbol= O :CSymbol= X raquo ;;
_ board [move_list.front ()]=cSymbol; val=MaxMove (_board, _player); (val lt; best_val) {_val=val;
}
_ board [move_list.front ()]=0; _list.pop_front ();
} best_val;
} MaxMove (char _board [9], player _player) {pos_value=evaluate_position (_board, _player); (pos_value!=- 1) {pos_value;
} best_val=-INFINITY; :: list lt; int gt; move_list; _moves (_board, move_list); (! move_list.empty ()) {
_ player.symbol == X ? cSymbol= X :CSymbol= O raquo ;;
_ board [move_list.front ()]=cSymbol; val=MinMove (_board, _player); (val gt; best_val) {_val=val;
}
_ board [move_list.front ()]=0; _list.pop_front ();
} best_val;
}