Maximilian Keßler
3244213daa
This now allows to import a light-weight header containing the abstract interface separately from the templated header that manages the actual backtracking, thus speeding up compilation.
45 lines
1.1 KiB
C++
45 lines
1.1 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";
|
|
break;
|
|
case ActionType::clue:
|
|
os << "clue";
|
|
break;
|
|
default:
|
|
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
|