Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SearchedState.hpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file
00003  */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef SEARCHEDSTATE_HPP
00007 #define SEARCHEDSTATE_HPP
00008 
00009 #include "Hex.hpp"
00010 #include "HexEval.hpp"
00011 
00012 _BEGIN_BENZENE_NAMESPACE_
00013 
00014 //----------------------------------------------------------------------------
00015 
00016 /** State that has been search with Alpha-Beta. */
00017 struct SearchedState
00018 {
00019     //------------------------------------------------------------------------
00020                          
00021     typedef enum { LOWER_BOUND, UPPER_BOUND, ACCURATE, NOT_DEFINED } Bound;
00022 
00023     //------------------------------------------------------------------------
00024 
00025     SearchedState()
00026         : hash(0), bound(NOT_DEFINED), score(0), move(INVALID_POINT),
00027           depth(0)
00028     { }
00029     
00030     SearchedState(hash_t h, int depth, Bound b, HexEval s, HexPoint m)
00031         : hash(h), bound(b), score(s), move(m), depth(depth)
00032     { }
00033 
00034     ~SearchedState();
00035     
00036     bool Initialized() const;
00037 
00038     hash_t Hash() const;
00039 
00040     void CheckCollision(const SearchedState& other) const;
00041 
00042     bool ReplaceWith(const SearchedState& other) const;
00043 
00044     //------------------------------------------------------------------------
00045 
00046     /** Zobrist Hash for this state. */
00047     hash_t hash;
00048    
00049     /** How the score should be interpreted. */
00050     Bound bound;
00051 
00052     /** Score for this state. */
00053     HexEval score;
00054 
00055     /** Best move found. */
00056     HexPoint move;
00057 
00058     /** Depth state was searched. */
00059     int depth;
00060 
00061 };
00062 
00063 inline SearchedState::~SearchedState()
00064 {
00065 }
00066 
00067 inline bool SearchedState::Initialized() const
00068 {
00069     return (move != INVALID_POINT);
00070 }
00071 
00072 inline hash_t SearchedState::Hash() const
00073 {
00074     return hash;
00075 }
00076 
00077 inline 
00078 void SearchedState::CheckCollision(const SearchedState& other) const
00079 {
00080     UNUSED(other);
00081 }
00082 
00083 inline bool SearchedState::ReplaceWith(const SearchedState& other) const
00084 {
00085     /** @todo check for better bounds/scores? */
00086 
00087     // replace this state only with a deeper state
00088     return (other.depth > depth);
00089 }
00090 
00091 //----------------------------------------------------------------------------
00092 
00093 _END_BENZENE_NAMESPACE_
00094 
00095 #endif // SEARCHEDSTATE_HPP


6 Jan 2011 Doxygen 1.6.3