container.cc
Go to the documentation of this file.
#include "osl/container.h"
#include "osl/eval/ptypeEval.h"
#include <iostream>
std::ostream& osl::operator<<(std::ostream& os,MoveVector const& mv)
{
os<< "MoveVector" << std::endl;
for (Move m: mv) {
os << m << std::endl;
}
return os<<std::endl;
}
bool osl::operator<(const MoveVector& l, const MoveVector& r)
{
return std::lexicographical_compare(l.begin(), l.end(),
r.begin(), r.end());
}
namespace osl
{
struct PieceBasicLessThan
{
bool operator()(Piece p0,Piece p1){
const Ptype ptype0=unpromote(p0.ptype());
const Ptype ptype1=unpromote(p1.ptype());
return (eval::Ptype_Eval_Table.value(ptype0)
< eval::Ptype_Eval_Table.value(ptype1));
}
};
struct PiecePtypeMoreThan
{
bool operator()(Piece p0,Piece p1){
const PtypeO ptypeo0=p0.ptypeO();
const PtypeO ptypeo1=p1.ptypeO();
return (abs(eval::Ptype_Eval_Table.captureValue(ptypeo0))
> abs(eval::Ptype_Eval_Table.captureValue(ptypeo1)));
}
};
} // namespace osl
void osl::PieceVector::sortByBasic()
{
std::sort(begin(),end(),PieceBasicLessThan());
}
void osl::PieceVector::sortByPtype()
{
std::sort(begin(),end(),PiecePtypeMoreThan());
}
#ifndef MINIMAL
std::ostream& osl::operator<<(std::ostream& os,PieceVector const& pv)
{
os << "PieceVector";
for (Piece p: pv) {
os << " " << p;
}
return os << std::endl;
}
#endif
struct osl::PtypeOSquareVector::PtypeOSquareLessThan
{
bool operator()(const std::pair<PtypeO,Square>& l,
const std::pair<PtypeO,Square>& r) {
const int vall = abs(eval::Ptype_Eval_Table.captureValue(l.first));
const int valr = abs(eval::Ptype_Eval_Table.captureValue(r.first));
if (vall != valr)
return vall < valr;
return l.second.uintValue() < r.second.uintValue();
}
};
void osl::PtypeOSquareVector::sort()
{
std::sort(begin(),end(),PtypeOSquareLessThan());
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::FixedCapacityVector::end
iterator end()
Definition container.h:199
osl::FixedCapacityVector::begin
iterator begin()
Definition container.h:198
osl::MoveVector
Definition container.h:293
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::PieceVector
Definition container.h:305
osl::PieceVector::sortByPtype
void sortByPtype()
駒の価値の大きい順に並び替える.
Definition container.cc:46
osl::PieceVector::sortByBasic
void sortByBasic()
駒の価値の小さい順に並び替える.
Definition container.cc:41
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptypeO
PtypeO ptypeO() const
Definition basic_type.h:824
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::PtypeOSquareVector::sort
void sort()
駒の価値の小さい順に並び替える
Definition container.cc:74
container.h
osl::eval::Ptype_Eval_Table
const PtypeEvalTable Ptype_Eval_Table
Definition tables.cc:103
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
osl::operator<
bool operator<(Offset l, Offset r)
Definition basic_type.h:520
osl::PtypeO
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition basic_type.h:199
osl::operator<<
std::ostream & operator<<(std::ostream &os, Player player)
Definition basic_type.cc:14
ptypeEval.h
osl::PieceBasicLessThan
Definition container.cc:22
osl::PieceBasicLessThan::operator()
bool operator()(Piece p0, Piece p1)
Definition container.cc:23
osl::PiecePtypeMoreThan
Definition container.cc:31
osl::PiecePtypeMoreThan::operator()
bool operator()(Piece p0, Piece p1)
Definition container.cc:32
osl::PtypeOSquareVector::PtypeOSquareLessThan
Definition container.cc:63
osl::PtypeOSquareVector::PtypeOSquareLessThan::operator()
bool operator()(const std::pair< PtypeO, Square > &l, const std::pair< PtypeO, Square > &r)
Definition container.cc:64