-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulation.cpp
More file actions
61 lines (47 loc) · 1.72 KB
/
Simulation.cpp
File metadata and controls
61 lines (47 loc) · 1.72 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
#include "Simulation.h"
#include <algorithm>
Simulation::Simulation() :
maxScore(0) {
}
Simulation::Simulation(const Simulation& otherSimulation) :
moves(otherSimulation.moves), maxScore(otherSimulation.maxScore) {
}
Simulation& Simulation::operator=(const Simulation& otherSimulation) {
moves = otherSimulation.moves;
maxScore = otherSimulation.maxScore;
return *this;
}
bool Simulation::operator<(const Simulation& otherSimulation) {
return maxScore < otherSimulation.maxScore;
}
void Simulation::addMove(const SlideDirection& direction) {
moves.push_back(direction);
}
void Simulation::addMove(const Coords& coords) {
moves.push_back(coords);
}
const SlideDirection& Simulation::getFirstMoveAsSlideDirection() {
return moves.begin()->direction;
}
const Coords& Simulation::getFirstMoveAsCoords() {
return moves.begin()->coords;
}
bool Simulation::checkFirstTwoMoves(const SlideDirection& direction1, const SlideDirection& direction2) const {
return moves[0].direction == direction1 && moves[1].direction == direction2;
}
bool Simulation::checkFirstTwoMoves(const SlideDirection& direction, const Coords& coords) const {
return moves[0].direction == direction && moves[1].coords == coords;
}
bool Simulation::checkFirstTwoMoves(const Coords& coords, const SlideDirection& direction) const {
return moves[0].coords == coords && moves[1].direction == direction;
}
bool Simulation::checkFirstTwoMoves(const Coords& coords1, const Coords& coords2) const {
return moves[0].coords == coords1 && moves[1].coords == coords2;
}
void Simulation::removeFirstTwo() {
moves.pop_front();
moves.pop_front();
}
std::size_t Simulation::getMovesCount() const {
return moves.size();
}