moveLogProb.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
moveLogProb.h
Go to the documentation of this file.
1 #ifndef OSL_MOVELOGPROB_H
2 #define OSL_MOVELOGPROB_H
3
4 #include "osl/move.h"
5 #include <iosfwd>
6
7 namespace osl
8 {
9 class MoveLogProb : private Move
10 {
11 int log_prob;
12 public:
13 MoveLogProb(Move m,int l) : Move(m),log_prob(l)
14 {
15 assert(m.isInvalid() || m.isValidOrPass());
16 }
17 MoveLogProb() : log_prob(0) {}
18
19 void setLogProb(int l) { log_prob=l; }
24 void setLogProbAtLeast(int l)
25 {
26 if (logProb() < l)
27 setLogProb(l);
28 }
33 void setLogProbAtMost(int l)
34 {
35 if (logProb() > l)
36 setLogProb(l);
37 }
38
39 const Move move()const{ return *this; }
40 int logProb()const{ return log_prob; }
41 bool validMove() const { return log_prob > 0; }
42
43 using Move::player;
44 using Move::isNormal;
45 using Move::isPass;
46 };
47 std::ostream& operator<<(std::ostream& os,MoveLogProb const& move);
48
49 inline bool operator==(MoveLogProb const& lhs,MoveLogProb const& rhs)
50 {
51 return lhs.move()==rhs.move() && lhs.logProb()==rhs.logProb();
52 }
53 inline bool operator<(MoveLogProb const& lhs,MoveLogProb const& rhs)
54 {
55 if (lhs.move() != rhs.move())
56 return lhs.move() < rhs.move();
57 return lhs.logProb() < rhs.logProb();
58 }
59
60 } // namespace ostream
61
62
63 #endif /* OSL_MOVELOGPROB_H */
64 // ;;; Local Variables:
65 // ;;; mode:c++
66 // ;;; c-basic-offset:2
67 // ;;; End: