-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathturniphelper.cpp
80 lines (64 loc) · 2.12 KB
/
turniphelper.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
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
#include "turniphelper.h"
void printReadTurnips(std::vector<Turnip *> &islandTurnips)
{
std::cout << "~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
std::cout << "READ IN TURNIP DATA" << std::endl
<< std::endl;
for (Turnip *t : islandTurnips)
{
std::cout << t << std::endl;
}
std::cout << "~~~~~~~~~~~~~~~~~~~~~~" << std::endl
<< std::endl;
}
std::vector<Turnip *> getTurnips(std::string &csv)
{
TurnipArt *splash = new TurnipArt();
std::cout << splash << std::endl;
delete splash;
std::cout << "Getting your turnip prices..." << std::endl;
Table stalkBucket = readCsv(csv);
std::cout << "Validating turnip prices..." << std::endl;
validateTurnips(stalkBucket);
std::cout << "Bucketing turnips..." << std::endl
<< std::endl;
std::vector<Turnip *> islandTurnips = tableToTurnip(stalkBucket);
if (islandTurnips.empty())
{
throw TurnipException(NO_ISLANDS);
}
return islandTurnips;
}
void predictTurnips(std::vector<Turnip *> &islandTurnips, AllPrices *allPrices)
{
int islands = islandTurnips.size();
int complete = 0;
std::cout << "Finding pattern matches for " << islands << " island(s)." << std::endl;
std::cout << std::endl;
for (auto &turnip : islandTurnips)
{
std::cout << "- On island " << complete + 1 << " out of " << islands << " -" << std::endl;
turnip->calculateLastInputDay();
if (turnip->getLastInputDay() == -1)
{ // -1 means that sat PM was filled in, so nothing to predict
std::cout << CANT_PREDICT << std::endl;
std::cout << turnip;
}
else
{
// predict from lastInputDay + 1 and onwards
std::cout << PREDICTING << std::endl;
std::cout << turnip;
turnip->predict(allPrices, complete + 1);
}
++complete;
}
std::cout << "Turnipin' in the stalk market done for " << complete << " island(s)." << std::endl;
}
void cleanupTurnips(std::vector<Turnip *> &islandTurnips)
{
for (Turnip *t : islandTurnips)
{
delete t;
}
}