84 lines
1.8 KiB
C++
84 lines
1.8 KiB
C++
#include "hanabi_types.hpp"
|
|
|
|
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:
|
|
os << "discard " + to_string(action.card);
|
|
break;
|
|
case ActionType::clue:
|
|
os << "clue";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return os;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
std::string to_string(const Hanabi::Card & card)
|
|
{
|
|
if (card == Hanabi::Cards::trash)
|
|
{
|
|
return "kt";
|
|
}
|
|
else
|
|
{
|
|
return Hanabi::suit_initials[card.suit] + std::to_string(5 - card.rank);
|
|
}
|
|
}
|
|
|
|
std::ostream & operator<<(std::ostream & os, const Card & card)
|
|
{
|
|
os << to_string(card);
|
|
return os;
|
|
}
|
|
|
|
std::ostream & print_probability(std::ostream & os, const rational_probability & prob)
|
|
{
|
|
os << prob << " ~ " << std::setprecision(5) << boost::rational_cast<double>(prob) * 100 << "%";
|
|
return os;
|
|
}
|
|
|
|
std::ostream & print_probability(std::ostream & os, double prob)
|
|
{
|
|
os << std::setprecision(5) << prob;
|
|
return os;
|
|
}
|
|
|
|
} // namespace Hanabi
|