-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
206 lines (144 loc) · 6.57 KB
/
notes.txt
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
FRONT END
Farm view: 15x15 grid, centered is original 3x3 farm plot, up to 9x9 farm plot, bordered on all sides by 2x2 grassland
<FarmGrid>
<Tile>
<Plant? />
</Tile>
</FarmGrid>
Inventory
market
farm status
buy new farm
account
(models)
To do: berry buy & sell, daily market prices
(routes)
crop, farm, geoProfile, market, user, auth
User accessible:
POST /auth/register
-> { username, email, password }
{ token } <-
POST /auth/login
-> { username, password }
{ token } <-
GET /users/:username (loggedIn, sameUser = hideSensitive is false)
GET /users/:username/farms (loggedIn)
DELETE /user/:username (loggedIn, sameUser)
GET /farms/:farmID
<- lastCheckedAt > 10 minutes ? -> sync
POST /farms/buy (loggedIn)
-> { locationID }
{ farm } <-
POST /farms/:farmID/upgrade (loggedIn, ownedBy)
- > { type : "irrigation" OR "length" OR "width" }
POST /farms/:farmID/crops (loggedIn, ownedBy)
- > { berryType, x, y }
POST /farms/:farmID/sync (loggedIn, ownedBy)
POST /crops (loggedIn, ownedBy) OR POST /farms/:farmID/crops
DELETE /crops/:cropID (loggedIn, ownedBy)
DELETE /farms/:farmID (loggedIn, ownedBy)
Admin only:
POST /farms
PATCH /farms
PATCH /user/:username
Growth process
growth_time = length of time (in hours) for each growth stage
Each berry grows in 4 stages
When a growth stage needs to be checked, we examine:
-Water level throughout the growth stage vs Water Requirement
-> The water req is how often the plant needs to be watered per growth stage
--> From API, this is a factor of soil_dryness
Examine: Last Watered Time, Last Growth Time, Current Time = Moisture
Moisture = Moisture - (Dry Rate * (Current Time vs Last Checked Time (seconds) / 3600))
--- Some of the following is outdated ---
Essentially, one of three scenarios occur when checking in on a plant:
1) The plant has not yet reached its growth stage.
2) The plant has reached a growth stage.
3) The plant has surpassed two or more growth stages.
The important thing is knowing what Moisture is at time of growth stage, which can be calculated.
If we're in Scenario 1, then it's a simple calculation of current time vs last watered time.
If we're in Scenario 2. We calculate growth time vs last watered time. Use that dryness level for plant health and growth calculations.
Then we update dryness based on amount of time between growth time and current time, this gives the current dryness.
If we're in Scenario 3, we iteratively step through each growth stage and do requisite calculations before finally grabbing the current
dryness.
Example:
Planting a Cheri Berry (Growth time: 3 hours, Water Req: 15)
The berry is planted at 0:00:00 AM. Last Watered is NULL. Moisture currently: 0%.
The berry is watered at 0:05:00 AM. Last Watered is 0:00:05 AM. Moisture currently: 100%.
The berry is checked at 2:30:00 AM. Last Watered is 0:00:05 AM. Moisture currently: 71.25%
-Sunlight level throughout the growth stage vs Sunlight Requirement
-Temperature throughout the growth stage vs Temperature Requirement
Weather
When a user checks their farm which is located in Location Y, and Y's geo_profile was last updated 24+ hours before the current time,
an API call is made to weather history API for day of current time. The API gives us hour-by-hour stats for that day.
We average out temperature, chance of rain, cloudiness, etc. for every forecasted/historical hour, and then save that to geo profile.
The only problem with this is that the weather data we use is the weather at the time the farm is checked, not necessarily when
growth stages occured. This could be alleviated by keeping a rolling history of Z days; any plants wilt after unattended for Z days.
So either we'll have the data in history, or the plant will be wilted anyway.
Question is, how to structure this in a relational DB schema? Create a weather averages table?
Here's where I feel a NoSQL DB would have the advantage.
---- Rain -> Moisture
0.0754
0.0970 mm
24 hour period = 2.33 mm of rain
On average, 0.09708 mm of rain every hour
totalRain * (timeDelta / (seconds in a day))
2.33 * (3600 / 86400) = 0.09708
2.33 * (1800 / 86400) = 0.04854
rainPerHour * (timeDelta / (seconds in an hour))
0.09708 * (1800 / 3600) = 0.04854
Louisiana (Wet state) Gets 4.186mm of rain a day
2.093mm every 12 hours
0.174mm every hour
Pecha (Water type berry) Loses 30 Moisture an hour (360 Moisture required over growth period)
1 moisture = 0.01mm of rain?
calcGrowth
input { health, moisture, idealTemp, idealCloud, avgTemp, avgCloud }
tempAvg = 100, idealTemp = 70
tempFactor = (100 / 70) - 1 = 0.42857...
tempMod = cos(0.42857) * 6 - 4.8 = 0.6574 // (bonus for within 26% of ideal)
cloudMod = cos(cloudFactor) * 3 - 1.85 // bonus for within 32% of ideal
The above method of temp/cloud factors favors higher ideal temps / avgs. There's more leeway
the more extreme the value. Whereas the closer the ideal is to 0 (and cannot divide by 0 to begin with),
the more punishing the most minute of difference.
Therefore, change the formula to use flat differences rather than ratios.
For temperature, +/- 5 degrees of ideal temp yields bonus (max bonus when at exactly ideal temp, of course)
For cloud, +/- 15% cloud level yields bonus (max bonus at exactly ideal cloud)
moisture = flat health adjustment
95 < moisture < 105 = +25 health
90 < moisture < 95 || 105 < moisture < 110 = +20 health
85-90 = +15 || 110-112
80-85 = +10 || 112-114
75-80 = +05 || 114-116
70-75 + 0 || 116-118
65-70 = -05 || 118-120
60-65 = -10 || 120-122
55-60 = -15 || 122-124
50-55 = -20 | 124-126
45-50 = -25 || 126-128
40-45 = -30 || 128-130
35-40 = -35 || 130-132
30-35 = -40 || 132-134
25-30 = -45 || 134-136
< 25 = -50 || 136-138
|| continues...
output (health * avg of temp and cloud mod) + moisture adjustment
Weather Berry Profile Type Adjustments
Normal = Milquetoast, 1x DryRate, 23c, 35% cloud
Fire = Hot and Sunny, 1x DryRate, 35c, 0% cloud
Water = Wet, 1.75x DryRate, 23c, 50% cloud
Grass = Warm, wet and sunny, 1.25x DryRate, 24c, 15% cloud
Electric = Cloudy weather, 16c, 100% cloud
Ice = Cold, 1x DryRate, -5c, 40% cloud
Fighting = 1x DryRate, 23c, 35% cloud
Poison = Hot and wet, 1.3x DryRate, 30c, 60% cloud
Ground = Dry, Hot and Sunny Climates, 0.25x DryRate, 32c, 10% cloud
Flying = Clear skies and balmy weather, 1x DryRate, 20c, 0% cloud
Psychic = 1x DryRate, 24c,
Bug = 1.25x, 26c, 50% cloud, 15% cloud
Rock = Dry, Warm Climates; 0.25x DryRate, 28c, 50% cloud
Ghost = Chilly, Cloudy weather 1x DryRate, 10c, 80% cloud
Dark = Cold weather, 1x DryRate, 5c, 50% cloud
Dragon = 1.2x DryRate, 16c, 80% cloud
Steel = 0.85x DryRate, 13c, 65% cloud
Fairy = Idyllic weather, 21c, 0% Cloud