-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieceNode.cpp
More file actions
39 lines (28 loc) · 795 Bytes
/
PieceNode.cpp
File metadata and controls
39 lines (28 loc) · 795 Bytes
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
#include <list>
#include "constants.h"
#include "Bitboard.h"
#include "PieceNode.h"
void PieceNode::reposition(list <PieceNode*> &newNeighbors, Bitboard &newBitboard){
remove();
insert(newNeighbors, newBitboard);
}
void PieceNode::insert( list <PieceNode*> &newNeighbors, Bitboard &newBitboard) {
for (auto otherNode: newNeighbors) {
otherNode -> neighbors.push_front(this);
neighbors.push_front(otherNode);
}
auto LSB = newBitboard.getLeastSignificantBit();
boardIndex = LSB.first;
location = LSB.second;
}
void PieceNode::remove() {
for (auto otherNode: neighbors) {
otherNode -> neighbors.remove(this);
}
neighbors.clear();
boardIndex = -1;
location = 0;
}
void PieceNode::print() {
cout << "boardIndex " << boardIndex << " location" << location << endl;
}