00001 /* position.cc 00002 */ 00003 #include "osl/position.h" 00004 #include <boost/static_assert.hpp> 00005 #include <iostream> 00006 00007 BOOST_STATIC_ASSERT(sizeof(osl::Position) == 4); 00008 00009 bool osl::Position::isOnBoardSlow() const 00010 { 00011 return (1<=x() && x() <=9 00012 && 1<=y() && y() <=9); 00013 } 00014 00015 bool osl::Position::isValid() const 00016 { 00017 return isPieceStand() || isOnBoard(); 00018 } 00019 00020 const osl::Position osl:: 00021 Position::positionForBlackSlow(Player player) const 00022 { 00023 if (player == BLACK) 00024 return *this; 00025 return Position(reverseX(x()),reverseY(y())); 00026 } 00027 00028 std::ostream& osl::operator<<(std::ostream& os, Position position) 00029 { 00030 if (position.isPieceStand()) 00031 return os << "OFF"; 00032 return os << "Position(" << position.x() << position.y() << ")"; 00033 } 00034 00035 /* ------------------------------------------------------------------------- */ 00036 // ;;; Local Variables: 00037 // ;;; mode:c++ 00038 // ;;; c-basic-offset:2 00039 // ;;; End: