diff --git a/game_state.hpp b/game_state.hpp index 02bfb66..22e7bfc 100644 --- a/game_state.hpp +++ b/game_state.hpp @@ -55,13 +55,12 @@ namespace Hanabi { template std::ostream &operator<<(std::ostream &os, const Stacks &stacks) { - for (size_t i = 0; i < stacks.size() - 1; i++) { - os << starting_card_rank - stacks[i]; + for (size_t i = 0; i < stacks.size(); i++) { + os << suit_initials[i] << starting_card_rank - stacks[i]; if(i < stacks.size() - 1) { os << ", "; } } - os << starting_card_rank - stacks.back(); return os; } @@ -235,22 +234,38 @@ namespace Hanabi { template void HanabiState::print(std::ostream &os) const { os << "Stacks: " << _stacks << " (score " << +_score << ")"; - os << ", clues: " << +_num_clues << ", turn: " << +_turn << std::endl; + os << ", clues: " << +_num_clues << ", turn: " << +_turn; + if (_endgame_turns_left != no_endgame) { + os << ", " << +_endgame_turns_left << " turns left"; + } + os << std::endl; os << "Draw pile: "; + unsigned num_trash = 0; for (const auto &[card, mul]: _draw_pile) { + if (is_trash(card)) { + num_trash += mul; + continue; + } os << card; if (mul > 1) { os << " (" << +mul << ")"; } os << ", "; } - os << "(size " << +_weighted_draw_pile_size << ")" << std::endl; + if (num_trash > 0) { + os << Cards::trash << " (" << num_trash << ") "; + } + os << "[size " << +_weighted_draw_pile_size << "]" << std::endl; os << "Hands: "; for (const auto &hand: _hands) { - for (const auto &card: hand) { - os << card << ", "; + os << "["; + for(hand_index_t index = 0; index < hand.size(); index++) { + os << hand[index]; + if (index < hand.size() - 1) { + os << " "; + } } - os << " | "; + os << "] "; } } diff --git a/main.cpp b/main.cpp index a93b399..ed9dd43 100644 --- a/main.cpp +++ b/main.cpp @@ -24,21 +24,12 @@ namespace Hanabi { std::cout << "Probability with optimal play: " << res << std::endl; std::cout << "Enumerated " << game->enumerated_states() << " states" << std::endl; std::cout << "Visited " << game->position_tablebase().size() << " unique game states. " << std::endl; - for (const auto &[action, probability] : game->get_reasonable_actions()) { - std::cout << action; - if(probability.has_value()) { - std::cout << " " << probability.value(); - } else { - std::cout << " unknown"; - } - std::cout << ", "; - } - std::cout << std::endl; unsigned long biggest_key = 0; for(const auto& [key, prob] : game->position_tablebase()) { biggest_key = std::max(biggest_key, key); } std::cout << "Biggest key generated is " << biggest_key << std::endl; + std::cout << std::endl; auto game_shared = std::shared_ptr(game.release()); auto states = game_shared->possible_next_states(0, false);