-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.h
88 lines (73 loc) · 1.87 KB
/
action.h
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
//
// Created by scorpion on 01.03.16.
//
#pragma once
#include "vertex.h"
struct Action {
public:
Action &getInstance() {
static Action instance;
return instance;
}
void setAction(actions type) {
actionType = type;
}
void setTime(int time) {
actionTime = time;
}
void setVertex(int v) {
actionVertex = v;
}
void setFirst(int first) {
firstP = first;
}
void setSecond(int second) {
secondP = second;
}
string getAction() {
string result = actionRepr[actionType];
if (actionType != actions::end)
result += " " + to_str(actionTime);
switch (actionType) {
case actions::move: {
result += " " + to_str(actionVertex);
break;
}
case actions::pick1: {
result += " " + to_str(firstP);
break;
}
case actions::drop1: {
result += " " + to_str(firstP);
break;
}
case actions::pick2: {
result += " " + to_str(firstP);
result += " " + to_str(secondP);
break;
}
case actions::drop2: {
result += " " + to_str(firstP);
result += " " + to_str(secondP);
break;
}
}
return result;
}
public:
Action() { }
string actionRepr[6] = {"move", "pick1", "pick2", "drop1", "drop2", "end"};
string to_str(int value) {
string ret = "";
if (value == 0)
return "0";
while (value > 0) {
ret.push_back('0' + (value % 10));
value /= 10;
}
reverse(ret.begin(), ret.end());
return ret;
}
actions actionType;
int actionTime, actionVertex, firstP, secondP;
};