piece.cc
Go to the documentation of this file.
00001 #include "osl/piece.h"
00002 #include "osl/ptypeTraits.h"
00003 #include <boost/static_assert.hpp>
00004 #include <iostream>
00005 #include <stdexcept>
00006 
00007 namespace osl
00008 {
00009   BOOST_STATIC_ASSERT(sizeof(Piece) == 4);
00010 } // namespace osl
00011 
00012 std::ostream& osl::operator<<(std::ostream& os,const Piece piece)
00013 {
00014   if (piece.isPiece())
00015     os << "Piece(" << piece.owner() << "," << piece.ptype() 
00016                << ",num=" << piece.number() 
00017                << "," << piece.square() << ')';
00018   else if (piece == Piece::EMPTY())
00019     os << "PIECE_EMPTY";
00020   else if (piece == Piece::EDGE())
00021     os << "PIECE_EDGE";
00022   else
00023     os << "unkown piece?!";
00024   return os;
00025 }
00026 
00027 const osl::Piece osl::Piece::makeKing(Player owner, Square position)
00028 {
00029   const int number = ((owner == BLACK)
00030                       ? (int)KingTraits<BLACK>::index
00031                       : (int)KingTraits<WHITE>::index);
00032   return Piece(owner, KING, number, position);
00033 }
00034 
00035 
00036 // ;;; Local Variables:
00037 // ;;; mode:c++
00038 // ;;; c-basic-offset:2
00039 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines