My Project
moveLogProb.h
Go to the documentation of this file.
1#ifndef OSL_MOVELOGPROB_H
2#define OSL_MOVELOGPROB_H
3
4#include "osl/basic_type.h"
5#include <iosfwd>
6
7namespace osl
8{
9 class MoveLogProb : private Move
10 {
12 public:
13 MoveLogProb(Move m,int l) : Move(m),log_prob(l)
14 {
15 assert(m.isInvalid() || m.isValidOrPass());
16 }
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:
int logProb() const
Definition moveLogProb.h:40
void setLogProbAtLeast(int l)
logProb を数字上最低 l にする.
Definition moveLogProb.h:24
void setLogProb(int l)
Definition moveLogProb.h:19
bool validMove() const
Definition moveLogProb.h:41
const Move move() const
Definition moveLogProb.h:39
void setLogProbAtMost(int l)
logProb を数字上最高 l にする.
Definition moveLogProb.h:33
MoveLogProb(Move m, int l)
Definition moveLogProb.h:13
圧縮していない moveの表現 .
bool isInvalid() const
state に apply 可能でない場合にtrue
Player player() const
bool isPass() const
bool isValidOrPass() const
bool isNormal() const
INVALID でも PASS でもない.
bool operator<(Offset l, Offset r)
Definition basic_type.h:520
std::ostream & operator<<(std::ostream &os, Player player)
Definition basic_type.cc:14
bool operator==(Square l, Square r)
Definition basic_type.h:758