fix lookup method to also include trivials cases
This commit is contained in:
parent
a95efaea4a
commit
f137f9f67c
2 changed files with 22 additions and 1 deletions
|
@ -273,9 +273,13 @@ namespace Hanabi {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prompt.starts_with("actions")) {
|
if (prompt.starts_with("actions")) {
|
||||||
for (const auto &[action, probability] : game->get_reasonable_actions()) {
|
auto reasonable_actions = game->get_reasonable_actions();
|
||||||
|
for (const auto &[action, probability] : reasonable_actions) {
|
||||||
std::cout << action << ": " << probability << std::endl;
|
std::cout << action << ": " << probability << std::endl;
|
||||||
}
|
}
|
||||||
|
if(reasonable_actions.empty()) {
|
||||||
|
std::cout << "Game is over, no actions to take." << std::endl;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,13 +297,23 @@ namespace Hanabi {
|
||||||
best_probability = probability;
|
best_probability = probability;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hand_index_t index = 0;
|
||||||
switch(best_action.type) {
|
switch(best_action.type) {
|
||||||
case ActionType::play:
|
case ActionType::play:
|
||||||
std::cout << "Playing " << best_action.card << std::endl;
|
std::cout << "Playing " << best_action.card << std::endl;
|
||||||
|
index = game->find_card_in_hand(best_action.card);
|
||||||
|
if(!ask_for_card_and_rotate_draw(game,index,true)) {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
game->play(game->find_card_in_hand(best_action.card));
|
game->play(game->find_card_in_hand(best_action.card));
|
||||||
break;
|
break;
|
||||||
case ActionType::discard:
|
case ActionType::discard:
|
||||||
std::cout << "Discarding" << std::endl;
|
std::cout << "Discarding" << std::endl;
|
||||||
|
index = game->find_card_in_hand(best_action.card);
|
||||||
|
if(!ask_for_card_and_rotate_draw(game, index, false)) {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
game->discard(game->find_card_in_hand(best_action.card));
|
game->discard(game->find_card_in_hand(best_action.card));
|
||||||
break;
|
break;
|
||||||
case ActionType::clue:
|
case ActionType::clue:
|
||||||
|
@ -309,6 +323,7 @@ namespace Hanabi {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Unrecognized command. Type 'help' for a list of available commands." << std::endl;
|
std::cout << "Unrecognized command. Type 'help' for a list of available commands." << std::endl;
|
||||||
|
|
|
@ -604,6 +604,12 @@ namespace Hanabi {
|
||||||
|
|
||||||
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
||||||
std::optional<probability_t> HanabiState<num_suits, num_players, hand_size>::lookup() const {
|
std::optional<probability_t> HanabiState<num_suits, num_players, hand_size>::lookup() const {
|
||||||
|
if (_score == 5 * num_suits) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (_pace < 0 or _endgame_turns_left == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
const auto id = unique_id();
|
const auto id = unique_id();
|
||||||
if(_position_tablebase.contains(id)) {
|
if(_position_tablebase.contains(id)) {
|
||||||
return _position_tablebase.at(id);
|
return _position_tablebase.at(id);
|
||||||
|
|
Loading…
Reference in a new issue