00001
00002
00003 #ifndef OSL_RATEDMOVE_H
00004 #define OSL_RATEDMOVE_H
00005
00006 #include "osl/move.h"
00007 #include <iosfwd>
00008
00009 namespace osl
00010 {
00011 namespace rating
00012 {
00013 class RatedMove
00014 {
00015 Move my_move;
00016 signed short all_rating, optimistic_rating;
00017 public:
00018 RatedMove(Move move, int rating, int optimistic) : my_move(move), all_rating(rating), optimistic_rating(optimistic)
00019 {
00020 }
00021 RatedMove(Move move, int rating) : my_move(move), all_rating(rating), optimistic_rating(rating)
00022 {
00023 }
00024 RatedMove() : all_rating(0), optimistic_rating(0) {}
00025 void setRating(int rating) { all_rating = rating; }
00026 void setOptimisticRating(int rating) { optimistic_rating = rating; }
00027
00028 const Move move() const { return my_move; }
00029 int rating() const { return all_rating; }
00030 int optimisticRating() const { return optimistic_rating; }
00031 };
00032
00033 std::ostream& operator<<(std::ostream& os, RatedMove const& moveLogProb);
00034
00035 inline bool operator==(RatedMove const& lhs, RatedMove const& rhs)
00036 {
00037 return lhs.move()==rhs.move() && lhs.rating()==rhs.rating();
00038 }
00039 inline bool operator<(RatedMove const& lhs, RatedMove const& rhs)
00040 {
00041 if (lhs.rating() != rhs.rating())
00042 return lhs.rating() < rhs.rating();
00043 if (lhs.optimisticRating() != rhs.optimisticRating())
00044 return lhs.optimisticRating() < rhs.optimisticRating();
00045 return lhs.move() < rhs.move();
00046 }
00047 inline bool operator>(RatedMove const& lhs, RatedMove const& rhs)
00048 {
00049 if (lhs.rating() != rhs.rating())
00050 return lhs.rating() > rhs.rating();
00051 if (lhs.optimisticRating() != rhs.optimisticRating())
00052 return lhs.optimisticRating() > rhs.optimisticRating();
00053 return lhs.move() < rhs.move();
00054 }
00055 }
00056 using rating::RatedMove;
00057 }
00058
00059
00060 #endif
00061
00062
00063
00064