-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPiece.cpp
More file actions
89 lines (62 loc) · 1.96 KB
/
Piece.cpp
File metadata and controls
89 lines (62 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Piece.cpp
// BCAI
//
// Created by Max Botviniev on 20.10.15.
// Copyright (c) 2015 Max Botviniev. All rights reserved.
//
#include "Piece.h"
namespace BCAI {
Piece::Piece() : position_v(Position('Z', 666)), score_v(777), white_v(6), type_v('E') {};
Piece::Piece(Position _position_v, unsigned int _score_v, bool _white_v, char _type_v) :
position_v(_position_v), score_v(_score_v), white_v(_white_v), type_v(_type_v) {
//std::cout << * this << " Created." << std::endl;
};
Piece::Piece(const Piece & _copy) :
position_v(_copy.position_v), score_v(_copy.score_v), white_v(_copy.white_v), type_v(_copy.type_v) {
axes = _copy.axes; //!!!
//std::cout << *this << " Copy constructed!" << std::endl;
};
//---------------------------
bool Piece::White() {
return white_v;
}
Position & Piece::GetPosition() {
return position_v;
}
unsigned int Piece::GetScore() {
return score_v;
}
char Piece::GetType() {
return type_v;
}
size_t Piece::Axes() {
return axes.size();
}
/*bool Piece::AlowedMove(const Board & board_r, const IndexPair & from, const IndexPair & to) {
std::cout << "Permited by Base Piece" << std::endl;
return true;
}*/
Piece::~Piece() {
//std::cout << * this << " - is Destroyed!" << std::endl;
}
void Piece::operator = ( Piece & other) {
if ( & other == this ) {
std::cout << "WASTE COPY: " << * this << std::endl;
}
//std::cout << other << " ASSIGNED TO: " << * this << std::endl;
position_v = other.position_v;
type_v = other.type_v;
white_v = other.white_v;
score_v = other.score_v;
axes = other.axes;
}
std::ostream & operator << (std::ostream & out, Piece & piece) {
out << "Piece Output || " <<
"Position: " << piece.GetPosition() <<
", Type: " << piece.GetType() <<
", Color: " << (piece.White() ? "White" : "Black") <<
", Axes: " << piece.Axes();
return out;
}
}