Endgame-Analyzer/src/hanabi_types.cpp

85 lines
1.8 KiB
C++
Raw Normal View History

#include "hanabi_types.hpp"
2023-11-16 16:20:04 +01:00
namespace Hanabi
{
std::ostream & operator<<(std::ostream & os, Action const & action)
{
switch (action.type)
{
case ActionType::play:
os << "play " + to_string(action.card);
break;
case ActionType::discard:
2024-01-13 03:39:53 +01:00
os << "discard " + to_string(action.card);
break;
case ActionType::clue:
os << "clue";
break;
default:
break;
}
return os;
}
2023-11-24 16:11:36 +01:00
std::ostream & operator<<(std::ostream & os, ActionType const & action_type)
{
switch (action_type)
{
case ActionType::play:
os << "play";
break;
case ActionType::discard:
os << "discard";
break;
case ActionType::color_clue:
os << "clue color";
break;
case ActionType::rank_clue:
os << "clue rank";
break;
case ActionType::end_game:
os << "end game";
break;
case ActionType::vote_terminate_players:
os << "vote termination";
break;
case ActionType::vote_terminate:
os << "terminate game";
break;
}
return os;
}
2023-11-16 16:20:04 +01:00
std::string to_string(const Hanabi::Card & card)
{
if (card == Hanabi::Cards::trash)
{
return "kt";
2023-11-16 16:20:04 +01:00
}
else
{
return Hanabi::suit_initials[card.suit] + std::to_string(5 - card.rank);
}
}
2023-11-16 16:20:04 +01:00
std::ostream & operator<<(std::ostream & os, const Card & card)
{
os << to_string(card);
return os;
}
2023-11-16 16:20:04 +01:00
std::ostream & print_probability(std::ostream & os, const rational_probability & prob)
{
os << prob << " ~ " << std::setprecision(5) << boost::rational_cast<double>(prob) * 100 << "%";
return os;
}
2023-11-16 16:20:04 +01:00
std::ostream & print_probability(std::ostream & os, double prob)
{
os << std::setprecision(5) << prob;
return os;
}
} // namespace Hanabi