My Project
container.cc
Go to the documentation of this file.
1#include "osl/container.h"
3#include <iostream>
4
5std::ostream& osl::operator<<(std::ostream& os,MoveVector const& mv)
6{
7 os<< "MoveVector" << std::endl;
8 for (Move m: mv) {
9 os << m << std::endl;
10 }
11 return os<<std::endl;
12}
13bool osl::operator<(const MoveVector& l, const MoveVector& r)
14{
15 return std::lexicographical_compare(l.begin(), l.end(),
16 r.begin(), r.end());
17}
18
19namespace osl
20{
22 {
23 bool operator()(Piece p0,Piece p1){
24 const Ptype ptype0=unpromote(p0.ptype());
25 const Ptype ptype1=unpromote(p1.ptype());
26 return (eval::Ptype_Eval_Table.value(ptype0)
27 < eval::Ptype_Eval_Table.value(ptype1));
28 }
29 };
31 {
32 bool operator()(Piece p0,Piece p1){
33 const PtypeO ptypeo0=p0.ptypeO();
34 const PtypeO ptypeo1=p1.ptypeO();
35 return (abs(eval::Ptype_Eval_Table.captureValue(ptypeo0))
36 > abs(eval::Ptype_Eval_Table.captureValue(ptypeo1)));
37 }
38 };
39} // namespace osl
40
42{
43 std::sort(begin(),end(),PieceBasicLessThan());
44}
45
47{
48 std::sort(begin(),end(),PiecePtypeMoreThan());
49}
50
51#ifndef MINIMAL
52std::ostream& osl::operator<<(std::ostream& os,PieceVector const& pv)
53{
54 os << "PieceVector";
55 for (Piece p: pv) {
56 os << " " << p;
57 }
58 return os << std::endl;
59}
60#endif
61
63{
64 bool operator()(const std::pair<PtypeO,Square>& l,
65 const std::pair<PtypeO,Square>& r) {
66 const int vall = abs(eval::Ptype_Eval_Table.captureValue(l.first));
67 const int valr = abs(eval::Ptype_Eval_Table.captureValue(r.first));
68 if (vall != valr)
69 return vall < valr;
70 return l.second.uintValue() < r.second.uintValue();
71 }
72};
73
75{
76 std::sort(begin(),end(),PtypeOSquareLessThan());
77}
78
79// ;;; Local Variables:
80// ;;; mode:c++
81// ;;; c-basic-offset:2
82// ;;; End:
圧縮していない moveの表現 .
void sortByPtype()
駒の価値の大きい順に並び替える.
Definition container.cc:46
void sortByBasic()
駒の価値の小さい順に並び替える.
Definition container.cc:41
PtypeO ptypeO() const
Definition basic_type.h:824
Ptype ptype() const
Definition basic_type.h:821
void sort()
駒の価値の小さい順に並び替える
Definition container.cc:74
const PtypeEvalTable Ptype_Eval_Table
Definition tables.cc:103
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition basic_type.h:157
bool operator<(Offset l, Offset r)
Definition basic_type.h:520
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition basic_type.h:199
std::ostream & operator<<(std::ostream &os, Player player)
Definition basic_type.cc:14
bool operator()(Piece p0, Piece p1)
Definition container.cc:23
bool operator()(Piece p0, Piece p1)
Definition container.cc:32
bool operator()(const std::pair< PtypeO, Square > &l, const std::pair< PtypeO, Square > &r)
Definition container.cc:64