-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMicroMove.cpp
42 lines (35 loc) · 1.4 KB
/
MicroMove.cpp
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
#include "MicroMove.h"
#include "Utility.h"
#include <iostream>
#include <string>
using namespace std;
MicroMove::MicroMove(char type, vector<pair<int, int>> moveInfo)
{
this->type = type;
this->moveInfo = moveInfo;
}
string MicroMove::cartesianToPolarString(int boardSize)
{
Utility util;
// cerr << "In MicroMove::cartesianToPolarString, moveInfo.size() = " << moveInfo.size() << endl;
// Transform into polar coordinates
vector<pair<int, int>> polarMoveInfo;
for (auto it = moveInfo.begin(); it != moveInfo.end(); it++)
{
polarMoveInfo.push_back(util.arrayToPolar(*it, boardSize));
}
switch (type)
{
case 'P':
return "P " + to_string(polarMoveInfo[0].first) + " " + to_string(polarMoveInfo[0].second) + " ";
case 'M':
return "S " + to_string(polarMoveInfo[0].first) + " " + to_string(polarMoveInfo[0].second) + " M " + to_string(polarMoveInfo[1].first) + " " + to_string(polarMoveInfo[1].second) + " ";
case 'R':
return "RS " + to_string(polarMoveInfo[0].first) + " " + to_string(polarMoveInfo[0].second) + " RE " + to_string(polarMoveInfo[1].first) + " " + to_string(polarMoveInfo[1].second) + " ";
case 'X':
return "X " + to_string(polarMoveInfo[0].first) + " " + to_string(polarMoveInfo[0].second) + " ";
default:
cerr << "Invalid type of move in MicroMove::cartesianToPolarString\n";
return "";
}
}