00001 /* square.cc 00002 */ 00003 #include "osl/square.h" 00004 #include "osl/boardTable.h" 00005 #include <boost/static_assert.hpp> 00006 #include <iostream> 00007 00008 BOOST_STATIC_ASSERT(sizeof(osl::Square) == 4); 00009 00010 bool osl::Square::isOnBoardSlow() const 00011 { 00012 return (1<=x() && x() <=9 00013 && 1<=y() && y() <=9); 00014 } 00015 00016 bool osl::Square::isValid() const 00017 { 00018 return isPieceStand() || isOnBoard(); 00019 } 00020 00021 const osl::Square osl:: 00022 Square::squareForBlackSlow(Player player) const 00023 { 00024 if (player == BLACK) 00025 return *this; 00026 return Square(reverseX(x()),reverseY(y())); 00027 } 00028 00029 00030 const osl::Square osl:: 00031 Square::neighbor(Player P, Direction D) const 00032 { 00033 return Board_Table.nextSquare(P, *this, D); 00034 } 00035 00036 const osl::Square osl:: 00037 Square::back(Player P, Direction D) const 00038 { 00039 return Board_Table.nextSquare(alt(P), *this, D); 00040 } 00041 00042 std::ostream& osl::operator<<(std::ostream& os, Square square) 00043 { 00044 if (square.isPieceStand()) 00045 return os << "OFF"; 00046 return os << "Square(" << square.x() << square.y() << ")"; 00047 } 00048 00049 /* ------------------------------------------------------------------------- */ 00050 // ;;; Local Variables: 00051 // ;;; mode:c++ 00052 // ;;; c-basic-offset:2 00053 // ;;; End: