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 |
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.
{
std::list<action> l;
typename std::list<action>::iterator it;
score best_eval;
Method method;
// actions jouables par l'ordi
current_state.nexts_actions( l );
best_eval = current_state.min_score();
for (it=l.begin(); it!=l.end(); ++it)
{
state* new_state;
score eval;
// on effectue chaque action
new_state = static_cast<state*>(current_state.do_action(*it));
// et on regarde ce qu'elle vaut.
eval = method(depth-1, *new_state, !computer_turn);
delete new_state;
// si c'est la meilleure, on la garde.
if (eval > best_eval)
{
best_eval = eval;
new_action = *it;
}
}
} // select_action::operator()
1.7.1