Sélection d'une action avec une méthode quelconque. More...
#include <game_ai.hpp>
Public Types | |
typedef Method::state | state |
typedef Method::action | action |
typedef Method::score | score |
Public Member Functions | |
void | operator() (int depth, const state ¤t_state, action &new_action, bool computer_turn) const |
Sélection d'une action. |
Sélection d'une action avec une méthode quelconque.
Definition at line 154 of file game_ai.hpp.
typedef Method::action claw::ai::game::select_action< Method >::action |
Definition at line 158 of file game_ai.hpp.
typedef Method::score claw::ai::game::select_action< Method >::score |
Definition at line 159 of file game_ai.hpp.
typedef Method::state claw::ai::game::select_action< Method >::state |
Definition at line 157 of file game_ai.hpp.
void claw::ai::game::select_action< Method >::operator() | ( | int | depth, | |
const state & | current_state, | |||
action & | new_action, | |||
bool | computer_turn | |||
) | const [inline] |
Sélection d'une action.
depth | Profondeur | |
current_state | Etat du jeu | |
new_action | entrée / sortie L'action selectionnée. Si aucune action n'a un score supérieur au score minimal, ce paramètre n'est pas modifié. | |
computer_turn | Indique si c'est au tour de l'ordinateur. |
Definition at line 342 of file game_ai.tpp.
00344 { 00345 std::list<action> l; 00346 typename std::list<action>::iterator it; 00347 score best_eval; 00348 Method method; 00349 00350 // actions jouables par l'ordi 00351 current_state.nexts_actions( l ); 00352 best_eval = current_state.min_score(); 00353 00354 for (it=l.begin(); it!=l.end(); ++it) 00355 { 00356 state* new_state; 00357 score eval; 00358 00359 // on effectue chaque action 00360 new_state = static_cast<state*>(current_state.do_action(*it)); 00361 // et on regarde ce qu'elle vaut. 00362 eval = method(depth-1, *new_state, !computer_turn); 00363 00364 delete new_state; 00365 00366 // si c'est la meilleure, on la garde. 00367 if (eval > best_eval) 00368 { 00369 best_eval = eval; 00370 new_action = *it; 00371 } 00372 } 00373 } // select_action::operator()