Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoSetup.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file GoSetup.h
00003     Initial setup information for GoBoard.
00004 */
00005 //----------------------------------------------------------------------------
00006 
00007 #ifndef GO_SETUP_H
00008 #define GO_SETUP_H
00009 
00010 #include "SgBlackWhite.h"
00011 #include "SgBWSet.h"
00012 #include "SgPoint.h"
00013 
00014 //----------------------------------------------------------------------------
00015 
00016 /** Setup information for start position in GoBoard. */
00017 class GoSetup
00018 {
00019 public:
00020     SgBWSet m_stones;
00021 
00022     SgBlackWhite m_player;
00023 
00024     /** Create empty setup.
00025         Contains no setup stones. Black is to move.
00026     */
00027     GoSetup();
00028 
00029     bool operator==(const GoSetup& setup) const;
00030 
00031     bool operator!=(const GoSetup& setup) const;
00032 
00033     /** Add a black stone.
00034         Convenience function. Equivalent to @c m_stones[SG_BLACK].Include(p)
00035     */
00036     void AddBlack(SgPoint p);
00037 
00038     /** Add a black stone.
00039         Convenience function. Equivalent to @c m_stones[SG_WHITE].Include(p)
00040     */
00041     void AddWhite(SgPoint p);
00042 
00043     /** Does the setup contain no setup stones and is the player Black. */
00044     bool IsEmpty() const;
00045 };
00046 
00047 inline GoSetup::GoSetup()
00048     : m_player(SG_BLACK)
00049 {
00050 }
00051 
00052 inline bool GoSetup::operator==(const GoSetup& setup) const
00053 {
00054     return (m_stones == setup.m_stones && m_player == setup.m_player);
00055 }
00056 
00057 inline bool GoSetup::operator!=(const GoSetup& setup) const
00058 {
00059     return ! operator==(setup);
00060 }
00061 
00062 inline void GoSetup::AddBlack(SgPoint p)
00063 {
00064     m_stones[SG_BLACK].Include(p);
00065 }
00066 
00067 inline void GoSetup::AddWhite(SgPoint p)
00068 {
00069     m_stones[SG_WHITE].Include(p);
00070 }
00071 
00072 inline bool GoSetup::IsEmpty() const
00073 {
00074     return (m_stones.BothEmpty() && m_player == SG_BLACK);
00075 }
00076 
00077 //----------------------------------------------------------------------------
00078 
00079 #endif // GO_SETUP_H
00080 


17 Jun 2010 Doxygen 1.4.7