00001 //---------------------------------------------------------------------------- 00002 /** @file DfsData.hpp 00003 */ 00004 //---------------------------------------------------------------------------- 00005 00006 #ifndef DFSDATA_H 00007 #define DFSDATA_H 00008 00009 #include "Hex.hpp" 00010 #include "ConstBoard.hpp" 00011 00012 _BEGIN_BENZENE_NAMESPACE_ 00013 00014 //---------------------------------------------------------------------------- 00015 00016 /** A solved state. Stored in a TT or DB. Matches 00017 TransTableStateConcept. 00018 Do not forget to update DFS_DB_VERSION if this class changes in a 00019 way that invalidiates old databases. 00020 */ 00021 struct DfsData 00022 { 00023 /** True if player to move wins. */ 00024 bool m_win; 00025 00026 /** Flags. */ 00027 int m_flags; 00028 00029 /** Number of states in proof-tree of this result. */ 00030 int m_numStates; 00031 00032 /** Number of moves losing player can delay until winning 00033 player has a winning virtual connection. */ 00034 int m_numMoves; 00035 00036 /** Best move in this state. 00037 Very important in winning states, not so important in losing 00038 states. That is, in winning states this move *must* be a 00039 winning move, in losing states this move is "most blocking", 00040 but the definition is fuzzy. */ 00041 HexPoint m_bestMove; 00042 00043 //-------------------------------------------------------------------- 00044 00045 /** Contructs state with default values. */ 00046 DfsData(); 00047 00048 /** Initializes state to given values. */ 00049 DfsData(bool w, int nstates, int nmoves, HexPoint bmove); 00050 00051 /** @name TransTableStateConcept */ 00052 // @{ 00053 00054 /** Returns true if this state is not the same as that built by 00055 the default constructor. */ 00056 bool Initialized() const; 00057 00058 /** If true, then this will give up its TT slot to other. 00059 @note ALWAYS RETURNS TRUE FOR NOW! */ 00060 bool ReplaceWith(const DfsData& other) const; 00061 00062 // @} 00063 00064 /** @name PositionDBStateConcept. */ 00065 // @{ 00066 00067 int PackedSize() const; 00068 00069 byte* Pack() const; 00070 00071 void Unpack(const byte* t); 00072 00073 void Rotate(const ConstBoard& brd); 00074 00075 void Mirror(const ConstBoard& brd); 00076 00077 // @} 00078 }; 00079 00080 inline DfsData::DfsData() 00081 : m_win(false), 00082 m_flags(0), 00083 m_numStates(0), 00084 m_numMoves(0), 00085 m_bestMove(INVALID_POINT) 00086 { 00087 } 00088 00089 inline DfsData::DfsData(bool w, int nstates, int nmoves, HexPoint bmove) 00090 : m_win(w), 00091 m_flags(0), 00092 m_numStates(nstates), 00093 m_numMoves(nmoves), 00094 m_bestMove(bmove) 00095 { 00096 } 00097 00098 inline bool DfsData::Initialized() const 00099 { 00100 return m_bestMove != INVALID_POINT; 00101 } 00102 00103 inline bool DfsData::ReplaceWith(const DfsData& other) const 00104 { 00105 UNUSED(other); 00106 return true; 00107 } 00108 00109 //---------------------------------------------------------------------------- 00110 00111 _END_BENZENE_NAMESPACE_ 00112 00113 #endif // DFSDATA_H