Initial commit
parent
ef0f82c5a3
commit
ea341cf6d3
@ -0,0 +1,107 @@
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Animal Crossing Turnip Price Forecaster</title>
|
||||
<meta name="description" content="Animal Crossing Turnip Price Forecaster">
|
||||
<meta name="author" content="Mike Bryant">
|
||||
|
||||
<link rel="stylesheet" href="css/styles.css?v=1.0">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>
|
||||
This tool is in early development - it will work best if you have all of the days data, morning and night.
|
||||
Without that it will not work hugely well.
|
||||
At a minimum this needs the buy price!
|
||||
</p>
|
||||
<form>
|
||||
<p>
|
||||
<label>Daisy Mae</label><br>
|
||||
<label>
|
||||
Buy price
|
||||
<input type="number" id="buy">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Monday</label><br>
|
||||
<label>
|
||||
AM
|
||||
<input type="number" id="sell_2">
|
||||
</label>
|
||||
<label>
|
||||
PM
|
||||
<input type="number" id="sell_3">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Tuesday</label><br>
|
||||
<label>
|
||||
AM
|
||||
<input type="number" id="sell_4">
|
||||
</label>
|
||||
<label>
|
||||
PM
|
||||
<input type="number" id="sell_5">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Wednesday</label><br>
|
||||
<label>
|
||||
AM
|
||||
<input type="number" id="sell_6">
|
||||
</label>
|
||||
<label>
|
||||
PM
|
||||
<input type="number" id="sell_7">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Thursday</label><br>
|
||||
<label>
|
||||
AM
|
||||
<input type="number" id="sell_8">
|
||||
</label>
|
||||
<label>
|
||||
PM
|
||||
<input type="number" id="sell_9">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Friday</label><br>
|
||||
<label>
|
||||
AM
|
||||
<input type="number" id="sell_10">
|
||||
</label>
|
||||
<label>
|
||||
PM
|
||||
<input type="number" id="sell_11">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Saturday</label><br>
|
||||
<label>
|
||||
AM
|
||||
<input type="number" id="sell_12">
|
||||
</label>
|
||||
<label>
|
||||
PM
|
||||
<input type="number" id="sell_13">
|
||||
</label>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<p>
|
||||
Your turnip prices will be one of the following patterns. Each range is the sell price for that day.
|
||||
</p>
|
||||
|
||||
<p id="output">
|
||||
</p>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
||||
<script src="js/scripts.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,211 @@
|
||||
function* generate_pattern_2(given_prices) {
|
||||
/*
|
||||
// PATTERN 2: consistently decreasing
|
||||
rate = 0.9;
|
||||
rate -= randfloat(0, 0.05);
|
||||
for (work = 2; work < 14; work++)
|
||||
{
|
||||
sellPrices[work] = intceil(rate * basePrice);
|
||||
rate -= 0.03;
|
||||
rate -= randfloat(0, 0.02);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
|
||||
|
||||
buy_price = given_prices[0];
|
||||
var predicted_prices = [
|
||||
{
|
||||
min: buy_price,
|
||||
max: buy_price,
|
||||
},
|
||||
{
|
||||
min: buy_price,
|
||||
max: buy_price,
|
||||
},
|
||||
];
|
||||
|
||||
var min_rate = 0.85;
|
||||
var max_rate = 0.9;
|
||||
for (var i = 2; i < 14; i++) {
|
||||
min_pred = Math.ceil(min_rate * buy_price);
|
||||
max_pred = Math.ceil(max_rate * buy_price);
|
||||
|
||||
|
||||
if (!isNaN(given_prices[i])) {
|
||||
if (given_prices[i] < min_pred || given_prices[i] > max_pred ) {
|
||||
// Given price is out of predicted range, so this is the wrong pattern
|
||||
return;
|
||||
}
|
||||
min_pred = given_prices[i];
|
||||
max_pred = given_prices[i];
|
||||
min_rate = given_prices[i] / buy_price;
|
||||
max_rate = given_prices[i] / buy_price;
|
||||
}
|
||||
|
||||
predicted_prices.push({
|
||||
min: min_pred,
|
||||
max: max_pred,
|
||||
});
|
||||
|
||||
min_rate -= 0.05;
|
||||
max_rate -= 0.03;
|
||||
}
|
||||
yield predicted_prices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function* generate_possibilities(sell_prices) {
|
||||
//yield* generate_pattern_0(sell_prices);
|
||||
//yield* generate_pattern_1(sell_prices);
|
||||
yield* generate_pattern_2(sell_prices);
|
||||
//yield* generate_pattern_3(sell_prices);
|
||||
}
|
||||
|
||||
$(document).on("input", function() {
|
||||
// Update output on any input change
|
||||
|
||||
/*
|
||||
void TurnipPrices::calculate()
|
||||
|
||||
whatPattern = nextPattern;
|
||||
|
||||
for (int i = 2; i < 14; i++)
|
||||
sellPrices[i] = 0;
|
||||
sellPrices[0] = basePrice;
|
||||
sellPrices[1] = basePrice;
|
||||
|
||||
int work;
|
||||
int decPhaseLen1, decPhaseLen2, peakStart;
|
||||
int hiPhaseLen1, hiPhaseLen2and3, hiPhaseLen3;
|
||||
float rate;
|
||||
|
||||
switch (whatPattern)
|
||||
{
|
||||
case 0:
|
||||
// PATTERN 0: high, decreasing, high, decreasing, high
|
||||
work = 2;
|
||||
decPhaseLen1 = randbool() ? 3 : 2;
|
||||
decPhaseLen2 = 5 - decPhaseLen1;
|
||||
|
||||
hiPhaseLen1 = randint(0, 6);
|
||||
hiPhaseLen2and3 = 7 - hiPhaseLen1;
|
||||
hiPhaseLen3 = randint(0, hiPhaseLen2and3 - 1);
|
||||
|
||||
// high phase 1
|
||||
for (int i = 0; i < hiPhaseLen1; i++)
|
||||
{
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * basePrice);
|
||||
}
|
||||
|
||||
// decreasing phase 1
|
||||
rate = randfloat(0.8, 0.6);
|
||||
for (int i = 0; i < decPhaseLen1; i++)
|
||||
{
|
||||
sellPrices[work++] = intceil(rate * basePrice);
|
||||
rate -= 0.04;
|
||||
rate -= randfloat(0, 0.06);
|
||||
}
|
||||
|
||||
// high phase 2
|
||||
for (int i = 0; i < (hiPhaseLen2and3 - hiPhaseLen3); i++)
|
||||
{
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * basePrice);
|
||||
}
|
||||
|
||||
// decreasing phase 2
|
||||
rate = randfloat(0.8, 0.6);
|
||||
for (int i = 0; i < decPhaseLen2; i++)
|
||||
{
|
||||
sellPrices[work++] = intceil(rate * basePrice);
|
||||
rate -= 0.04;
|
||||
rate -= randfloat(0, 0.06);
|
||||
}
|
||||
|
||||
// high phase 3
|
||||
for (int i = 0; i < hiPhaseLen3; i++)
|
||||
{
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * basePrice);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// PATTERN 1: decreasing middle, high spike, random low
|
||||
peakStart = randint(3, 9);
|
||||
rate = randfloat(0.9, 0.85);
|
||||
for (work = 2; work < peakStart; work++)
|
||||
{
|
||||
sellPrices[work] = intceil(rate * basePrice);
|
||||
rate -= 0.03;
|
||||
rate -= randfloat(0, 0.02);
|
||||
}
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * basePrice);
|
||||
sellPrices[work++] = intceil(randfloat(1.4, 2.0) * basePrice);
|
||||
sellPrices[work++] = intceil(randfloat(2.0, 6.0) * basePrice);
|
||||
sellPrices[work++] = intceil(randfloat(1.4, 2.0) * basePrice);
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * basePrice);
|
||||
for (; work < 14; work++)
|
||||
{
|
||||
sellPrices[work] = intceil(randfloat(0.4, 0.9) * basePrice);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
||||
case 3:
|
||||
// PATTERN 3: decreasing, spike, decreasing
|
||||
peakStart = randint(2, 9);
|
||||
|
||||
// decreasing phase before the peak
|
||||
rate = randfloat(0.9, 0.4);
|
||||
for (work = 2; work < peakStart; work++)
|
||||
{
|
||||
sellPrices[work] = intceil(rate * basePrice);
|
||||
rate -= 0.03;
|
||||
rate -= randfloat(0, 0.02);
|
||||
}
|
||||
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * (float)basePrice);
|
||||
sellPrices[work++] = intceil(randfloat(0.9, 1.4) * basePrice);
|
||||
rate = randfloat(1.4, 2.0);
|
||||
sellPrices[work++] = intceil(randfloat(1.4, rate) * basePrice) - 1;
|
||||
sellPrices[work++] = intceil(rate * basePrice);
|
||||
sellPrices[work++] = intceil(randfloat(1.4, rate) * basePrice) - 1;
|
||||
|
||||
// decreasing phase after the peak
|
||||
if (work < 14)
|
||||
{
|
||||
rate = randfloat(0.9, 0.4);
|
||||
for (; work < 14; work++)
|
||||
{
|
||||
sellPrices[work] = intceil(rate * basePrice);
|
||||
rate -= 0.03;
|
||||
rate -= randfloat(0, 0.02);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
sellPrices[0] = 0;
|
||||
sellPrices[1] = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
var buy_price = parseInt($("#buy").val());
|
||||
|
||||
var sell_prices = [buy_price, buy_price];
|
||||
for (var i = 2; i < 14; i++) {
|
||||
sell_prices.push(parseInt($("#sell_" + i).val()));
|
||||
}
|
||||
|
||||
var output_possibilities = "";
|
||||
for (let poss of generate_possibilities(sell_prices)) {
|
||||
var out_line = ""
|
||||
for (let day of [...poss].slice(2)) {
|
||||
out_line += day.min + ".." + day.max + " "
|
||||
}
|
||||
output_possibilities += out_line + "<br>"
|
||||
}
|
||||
|
||||
$("#output").html(output_possibilities)
|
||||
})
|
Loading…
Reference in New Issue