00001
00002 #include "osl/container/pieceValues.h"
00003 #include "osl/state/simpleState.h"
00004 #include <boost/foreach.hpp>
00005 #include <iostream>
00006 #include <iomanip>
00007
00008 osl::container::
00009 PieceValues::PieceValues()
00010 {
00011 }
00012
00013 osl::container::
00014 PieceValues::~PieceValues()
00015 {
00016 }
00017
00018 int osl::container::
00019 PieceValues::sum() const
00020 {
00021 int result = 0;
00022 BOOST_FOREACH(int v, *this)
00023 {
00024 result += v;
00025 }
00026 return result;
00027 }
00028
00029 #ifndef MINIMAL
00030 void osl::container::
00031 PieceValues::showValues(std::ostream& os, const SimpleState& state) const
00032 {
00033 for (int y=1;y<=9;y++) {
00034 os << y;
00035 for (int x=9;x>0;x--) {
00036 const Piece piece = state.getPieceOnBoard(Position(x,y));
00037 os << std::setw(7);
00038 if (piece.isEmpty())
00039 os << 0;
00040 else
00041 os << (*this)[piece.number()];
00042 }
00043 os << std::endl;
00044 }
00045 os << "black stand: ";
00046 for (int i=0; i<Piece::SIZE; ++i)
00047 {
00048 const Piece piece = state.getPieceOf(i);
00049 if ((piece.owner() == BLACK)
00050 && (piece.position().isPieceStand()))
00051 os << piece.ptype() << " " << (*this)[piece.number()] << " ";
00052 }
00053 os << "\n";
00054 os << "white stand: ";
00055 for (int i=0; i<Piece::SIZE; ++i)
00056 {
00057 const Piece piece = state.getPieceOf(i);
00058 if ((piece.owner() == WHITE)
00059 && (piece.position().isPieceStand()))
00060 os << piece.ptype() << " " << (*this)[piece.number()] << " ";
00061 }
00062 os << "\n";
00063 os << "total: " << sum() << "\n";
00064 }
00065 #endif
00066
00067
00068
00069