説明を見る。00001 #include "osl/container.h"
00002 #include "osl/eval/ptypeEval.h"
00003 #include <iostream>
00004
00005 std::ostream& osl::operator<<(std::ostream& os,MoveVector const& mv)
00006 {
00007 os<< "MoveVector" << std::endl;
00008 for (Move m: mv) {
00009 os << m << std::endl;
00010 }
00011 return os<<std::endl;
00012 }
00013 bool osl::operator<(const MoveVector& l, const MoveVector& r)
00014 {
00015 return std::lexicographical_compare(l.begin(), l.end(),
00016 r.begin(), r.end());
00017 }
00018
00019 namespace osl
00020 {
00021 struct PieceBasicLessThan
00022 {
00023 bool operator()(Piece p0,Piece p1){
00024 const Ptype ptype0=unpromote(p0.ptype());
00025 const Ptype ptype1=unpromote(p1.ptype());
00026 return (eval::Ptype_Eval_Table.value(ptype0)
00027 < eval::Ptype_Eval_Table.value(ptype1));
00028 }
00029 };
00030 struct PiecePtypeMoreThan
00031 {
00032 bool operator()(Piece p0,Piece p1){
00033 const PtypeO ptypeo0=p0.ptypeO();
00034 const PtypeO ptypeo1=p1.ptypeO();
00035 return (abs(eval::Ptype_Eval_Table.captureValue(ptypeo0))
00036 > abs(eval::Ptype_Eval_Table.captureValue(ptypeo1)));
00037 }
00038 };
00039 }
00040
00041 void osl::PieceVector::sortByBasic()
00042 {
00043 std::sort(begin(),end(),PieceBasicLessThan());
00044 }
00045
00046 void osl::PieceVector::sortByPtype()
00047 {
00048 std::sort(begin(),end(),PiecePtypeMoreThan());
00049 }
00050
00051 #ifndef MINIMAL
00052 std::ostream& osl::operator<<(std::ostream& os,PieceVector const& pv)
00053 {
00054 os << "PieceVector";
00055 for (Piece p: pv) {
00056 os << " " << p;
00057 }
00058 return os << std::endl;
00059 }
00060 #endif
00061
00062 struct osl::PtypeOSquareVector::PtypeOSquareLessThan
00063 {
00064 bool operator()(const std::pair<PtypeO,Square>& l,
00065 const std::pair<PtypeO,Square>& r) {
00066 const int vall = abs(eval::Ptype_Eval_Table.captureValue(l.first));
00067 const int valr = abs(eval::Ptype_Eval_Table.captureValue(r.first));
00068 if (vall != valr)
00069 return vall < valr;
00070 return l.second.uintValue() < r.second.uintValue();
00071 }
00072 };
00073
00074 void osl::PtypeOSquareVector::sort()
00075 {
00076 std::sort(begin(),end(),PtypeOSquareLessThan());
00077 }
00078
00079
00080
00081
00082