Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HexEval.hpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file
00003  */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef HEXEVAL_H
00007 #define HEXEVAL_H
00008 
00009 #include "Hex.hpp"
00010 
00011 _BEGIN_BENZENE_NAMESPACE_
00012 
00013 //----------------------------------------------------------------------------
00014 
00015 /** Data type for storing evaluation scores. */
00016 typedef double HexEval;
00017 
00018 //----------------------------------------------------------------------------
00019 
00020 /** (HexPoint, value) pairs; use for move ordering. */
00021 class HexMoveValue
00022 {
00023 public:
00024     HexMoveValue()
00025     : m_point(INVALID_POINT),
00026       m_value(0.0)
00027     { }
00028     HexMoveValue(HexPoint point, double value)
00029         : m_point(point),
00030           m_value(value)
00031     { }
00032     
00033     HexPoint point() const { return m_point; }
00034     double value() const { return m_value; }
00035 
00036     bool operator< (const HexMoveValue& other) const
00037     {
00038         return m_value < other.m_value;
00039     }
00040 
00041     bool operator> (const HexMoveValue& other) const
00042     {
00043         return m_value > other.m_value;
00044     }
00045     
00046 private:
00047     HexPoint m_point;
00048     double m_value;
00049 };
00050 
00051 //----------------------------------------------------------------------------
00052 
00053 /** Scores >= WIN_THRESHOLD are wins and scores <= LOSS_THRESHOLD are
00054     losses.  The difference between a score and IMMEDIATE_WIN or
00055     IMMEDIATE_LOSS should correspond directly with the number of ply
00056     to win or lose.  For example, a win in 5 moves should have score
00057     IMMEDIATE_WIN - 5 >= WIN_THRESHOLD.
00058 */
00059 static const HexEval  IMMEDIATE_WIN =  10000.0;
00060 static const HexEval  WIN_THRESHOLD =   9000.0; 
00061 static const HexEval LOSS_THRESHOLD =  -9000.0;
00062 static const HexEval IMMEDIATE_LOSS = -10000.0;
00063 
00064 static const HexEval EVAL_INFINITY = 1000000.0;
00065 
00066 namespace HexEvalUtil
00067 {
00068     bool IsValidEval(HexEval ev);
00069 
00070     bool IsWin(HexEval ev);
00071     int PlyToWin(HexEval ev);
00072 
00073     bool IsLoss(HexEval ev);
00074     int PlyToLoss(HexEval ev);
00075 
00076     bool IsWinOrLoss(HexEval ev);
00077 }
00078 
00079 //----------------------------------------------------------------------------
00080 
00081 _END_BENZENE_NAMESPACE_
00082 
00083 #endif // HEXEVAL_H


6 Jan 2011 Doxygen 1.6.3