My Project
core
osl
container.cc
Go to the documentation of this file.
1
#include "
osl/container.h
"
2
#include "
osl/eval/ptypeEval.h
"
3
#include <iostream>
4
5
std::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
}
13
bool
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
19
namespace
osl
20
{
21
struct
PieceBasicLessThan
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
};
30
struct
PiecePtypeMoreThan
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
41
void
osl::PieceVector::sortByBasic
()
42
{
43
std::sort(
begin
(),
end
(),
PieceBasicLessThan
());
44
}
45
46
void
osl::PieceVector::sortByPtype
()
47
{
48
std::sort(begin(),end(),
PiecePtypeMoreThan
());
49
}
50
51
#ifndef MINIMAL
52
std::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
62
struct
osl::PtypeOSquareVector::PtypeOSquareLessThan
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
74
void
osl::PtypeOSquareVector::sort
()
75
{
76
std::sort(begin(),end(),
PtypeOSquareLessThan
());
77
}
78
79
// ;;; Local Variables:
80
// ;;; mode:c++
81
// ;;; c-basic-offset:2
82
// ;;; 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
Generated by
1.12.0