1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/* analysesResult.cc
*/
#include "osl/annotate/analysesResult.h"
#include "osl/misc/carray.h"
#include <boost/foreach.hpp>
bool osl::annotate::operator==(const AnalysesResult& l, const AnalysesResult& r)
{
return l.repetition == r.repetition
&& l.checkmate == r.checkmate
&& l.checkmate_win == r.checkmate_win
&& l.threatmate == r.threatmate
&& l.escape_from_check == r.escape_from_check
&& l.threatmate_probability == r.threatmate_probability
&& l.threatmate_node_count == r.threatmate_node_count
&& l.checkmate_for_capture == r.checkmate_for_capture
&& l.checkmate_for_escape == r.checkmate_for_escape
&& l.threatmate_if_more_pieces == r.threatmate_if_more_pieces;
}
std::ostream& osl::annotate::operator<<(std::ostream& os, Trivalent t)
{
static const CArray<const char*,3> str = {{
"False", "Unknown", "True",
}};
return os << str[t+1];
}
#define out(os, shared, x) os << #x << " " << shared.x << " "
template <class T> void outt(std::ostream& os, const T& a, const char *str)
{
if (a != T())
os << str << " " << a << " ";
}
#define outif(os, shared, x) outt(os, shared.x, #x)
std::ostream& osl::annotate::operator<<(std::ostream& os, const AnalysesResult& shared)
{
if (! shared.repetition.empty()) {
os << "repetition ";
BOOST_FOREACH(int p, shared.repetition)
os << p << " ";
os << " ";
}
if (shared.checkmate != False)
out(os, shared, checkmate);
if (shared.threatmate != False)
out(os, shared, threatmate);
if (shared.escape_from_check != False)
out(os, shared, escape_from_check);
outif(os, shared, checkmate_move);
outif(os, shared, threatmate_move);
outif(os, shared, threatmate_probability);
outif(os, shared, threatmate_node_count);
outif(os, shared, checkmate_for_capture.safe_count);
outif(os, shared, checkmate_for_capture.checkmate_count);
outif(os, shared, checkmate_for_capture.see_plus_checkmate_count);
outif(os, shared, checkmate_for_escape.safe_count);
outif(os, shared, checkmate_for_escape.checkmate_count);
if (! shared.threatmate_if_more_pieces.hand_ptype.empty())
{
os << "hand ";
BOOST_FOREACH(Ptype ptype, shared.threatmate_if_more_pieces.hand_ptype)
os << ptype << " ";
os << " ";
}
if (! shared.threatmate_if_more_pieces.board_ptype.empty())
{
os << "board ";
BOOST_FOREACH(Piece piece, shared.threatmate_if_more_pieces.board_ptype)
os << piece << " ";
os << " ";
}
return os;
}
#undef out
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|