TwoDistance.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef TWODISTANCE_HPP
00007 #define TWODISTANCE_HPP
00008
00009 #include "Hex.hpp"
00010 #include "HexEval.hpp"
00011 #include "HexBoard.hpp"
00012
00013 _BEGIN_BENZENE_NAMESPACE_
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class TwoDistance
00033 {
00034 public:
00035
00036
00037
00038
00039
00040
00041 typedef enum { ADJACENT, FULL_VC } NeighbourType;
00042
00043
00044
00045 explicit TwoDistance(NeighbourType ntype = ADJACENT);
00046
00047
00048 virtual ~TwoDistance();
00049
00050
00051 virtual void Evaluate(const HexBoard& brd);
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 virtual HexEval Score() const;
00067
00068
00069
00070 virtual HexEval Score(HexPoint cell) const;
00071
00072
00073
00074 virtual HexEval Score(HexPoint cell, HexColor color) const;
00075
00076 private:
00077
00078 void ComputeScores(HexColor color, HexEval* out);
00079
00080 void FindBest(HexEval* po, HexPoint& who, int& count);
00081
00082 void ComputeScore();
00083
00084 void ComputeDistanceToEdge(HexColor color, HexPoint edge1, HexEval* out);
00085
00086 bool IsAdjacent(HexColor color, HexPoint p1, HexPoint p2);
00087
00088 void SetAllToInfinity(HexEval* out);
00089
00090 const HexBoard* m_brd;
00091 NeighbourType m_ntype;
00092
00093 HexEval m_score;
00094 HexEval m_scores[BLACK_AND_WHITE][BITSETSIZE];
00095 };
00096
00097 inline HexEval TwoDistance::Score() const
00098 {
00099 return m_score;
00100 }
00101
00102 inline HexEval TwoDistance::Score(HexPoint cell, HexColor color) const
00103 {
00104
00105 return m_scores[color][cell];
00106 }
00107
00108 inline HexEval TwoDistance::Score(HexPoint cell) const
00109 {
00110
00111 return m_scores[BLACK][cell] + m_scores[WHITE][cell];
00112 }
00113
00114
00115
00116 namespace TwoDistUtil
00117 {
00118
00119 HexEval AddDistance(HexEval a, HexEval b);
00120 }
00121
00122
00123
00124 _END_BENZENE_NAMESPACE_
00125
00126 #endif // TWODISTANCE_HPP