ensingm2 / SteamMonsterGameScript

A Javascript automator for the 2015 Summer Steam Monster Minigame
78 stars 29 forks source link

buying cheap upgrades #124

Open mawilek opened 9 years ago

mawilek commented 9 years ago

How about automatically buying everything that's already too cheap? When your next aim is say >100B, it would be already time to get all upgrades up to at least 100k. I would say, take the price of your next aim and buy everything that is 100000 times cheaper, or 10000 or maybe even 1000. While it won't have a great impact, it's still better to have extra autoclick or trophies for hours then just geting your next titanium button a minute earlier.

vanZeben commented 9 years ago

The way that it works is the script calculates which upgrade would yeild the best damage/(dollar/coin/whatever you want to call it), so while you may have more of a smaller upgrade, you will eventually be paying more to upgrade the same amount as the higher upgrade..

It also takes into account any multipliers to calculate this

ensingm2 commented 9 years ago

Actually, he has a point. If you want to be super accurate, you have to take the damage done by the 'smaller' upgrade over the period of time you'll have to wait for the bigger one. I've been sitting here for the past 20 minutes typing and trying to think through a solution. It's rough.

I'm not sure it'll be worth implementing, but I want to see if I can at least figure out the basic logic behind it. I'll post here when I figure things out.

mawilek commented 9 years ago

If the game would be endless, it would actually be better to have a priority over the best DPS. But since the game is limited to 24 hours, the earlier we get the updates, the more impact they have. A cheap autoclick bought on the first hour might be better than a huge dps grow in last minutes. Especially since there are many people that can't just be online for 24 hours straight. Also i'm not sure, why don't you buy abilities automatically. I might have missed that conversation, but I was sad when i suddenly noticed i'm not using abilities several hours after reset. I bought them manually, but i'm sure there are a lot of people, starting the script and going away for hours, hoping it will do everything possible by itself:)

ensingm2 commented 9 years ago

OK, I think I figured it out.

We currently do a direct dps per gold check between upgrades, and assume they would be bought at the same time.

To fix this, we would need to rework the damage checking function to look at the difference in damage between the two options for the duration of time that the 'timelines' will be different (in between the time we have neither upgrade and the time we have both)

upgrA (smaller) vs upgrB(larger):

var goldPerSec= getAvgGoldPerSec(); // Maybe over the last 10 rounds (a Boss Cycle?)
var upgrA.timeCost = upgrA.cost / goldPerSec;
var dmgBonus = upgrA.dps * (timeUntilBuyable(upgrB) + upgrA.timeCost); //Damage done in the meantime
var dmgPenalty = (upgrB.dps * upgrA.timeCost) // Damage lost due to delaying bigger upgrade
var dmgDiff = dmgBonus - dmgPenalty;

if (dmgDiff > 0)
    buy(upgrA);
else
    buy(upgrB);

...Right?

Obligitory Shitty MSPaint Drawing: image

Ugh, I'm too tired to think. I'll come back tomorrow and read this and realize how flawed my logic was or something. Going to sleep.

ensingm2 commented 9 years ago

@mawilek It isn't even as complicated as you mentioned. You can ignore most of the 'timeline' as beyond the point of time where you buy upgrades, your future damage potential doesn't depend on your choices. So you only have to take into account total damage differences in the time between buying the two upgrades.

I _think_ my above post covers it, with the exception of checking to make sure you don't check beyond the time limit of the game. Let me know if I'm mistaken. Time to sleep.

ensingm2 commented 9 years ago

Also i'm not sure, why don't you buy abilities automatically. I might have missed that conversation, but I was sad when i suddenly noticed i'm not using abilities several hours after reset. I bought them manually, but i'm sure there are a lot of people, starting the script and going away for hours, hoping it will do everything possible by itself:)

@meishuu added this, probably because there's not a good, objective comparator for abilities like there is with DPS. Though I guess you can try to project and maximize the potential damage based on the rest of the game.

you _can_ type autoBuyAbilities=true into the console and it should buy them for you, however.

meishuu commented 9 years ago

Yeah, I'm sitting here staring at it trying to buy Titanium Mouse Button at 26,559M while leaving New Mouse Button at 2,655M and Railgun at 265M, and wondering which order would be best.

Maybe I'm overthinking this but we basically need to be able to figure out income (i.e., gold over time), which is kind of difficult to predict with boss level farms (?). Lotsa variables going on there. I'm sure we could figure out some algorithm for smartly figuring this stuff out, it's just a matter of getting something solid before the minigame's over.

And yes, I disabled buying abilities by default because it's probably smarter to let people manage those manually. If we figured out income we could probably also be smarter with those.

ensingm2 commented 9 years ago

I'd just keep 2 arrays of length 10, one to keep track of gold count at the start of each level, one to keep track of timestamp, then roll out the oldest levels as you progress to a new one. That way you can take the last 10 levels ( cause you probably want a full 'cycle'), and average them to get income. It's not perfect since it increases over time, but it should be close enough at least. Maybe add a * 1.1 multiplier to estimate gold increase over levelsl for kicks and see what happens?

mawilek commented 9 years ago

@ensingm2 that's a good logic but still not ideal. Let's say we have upgrades A1, A2 and B. B is a smaller upgrade and A2 is not available before we buy A1. If you logic is up, we may buy A1 instead of B because A1 is more efective at this point. Then, when A1 is bought and we compare A2 and B at the current moment, A2 might still be better. But if we compared B and A2 before getting A1 we may have found, the biggest damage would be dealt if we start with B and then go to A1 and A2.

Now the question is how to find the x, to compare B with Ax at the very start of the game, where Ax is the last upgrade we will buy in the An line. Since it is already hard to find out gps in a short period (it may take dozen boss-cycles to get next upgrade, and every boss cycle obviously gives more money) It will be totally impossible to know how much gold will we have in ~20 hours.

My point is still 100k is a couple of seconds worth of time in the middle game and spending those won't influence much on the time we buy an expensive upgrade. Being offline for a minue will have a greater impact. than that.

Its an MMO game, and the purpose of this script is to improve performance of an average player, not some individuals. While an individual can play beter, than a script, a performance of an average player has much greater impact on the final result. An average player doesn't play 24 hours, he does not use console commands and he makes counter productive decisions on what to buy when he has spare money. Also with a significant offline time it is worth upgrading autofire damage to some good enough state, while prioritising to click damage ofcourse. I'm sure it's worth getting to Level 1 Sentry Gun by the middle game, while your script won't even get past the AFK Equipment 10 unless it is helped to. It's impossible to guess the best tactics, that's why i suggest to fix strategy errors on the go. When the upgrades become insignificantly cheap, it's better to buy them and loose a couple of seconds (i'm pretty sure, those will be lost anyway at some moment), then to pass.

mawilek commented 9 years ago

Let's say we have upgrades A1, A2 and B. B is a smaller upgrade and A2 is not available before we buy A1. If you logic is up, we may buy A1 instead of B because A1 is more efective at this point. Then, when A1 is bought and we compare A2 and B at the current moment, A2 might still be better. But if we compared B and A2 before getting A1 we may have found, the biggest damage would be dealt if we start with B and then go to A1 and A2.

I'm sorry, that's actually not true.

ensingm2 commented 9 years ago

So before I code up my earlier logic, are people in agreement that it's correct and efficient enough? Making a projected upgrade tree optimizing all possible routes is a bit complicated for this so I'll probably just stick to the direct comparison of 2 upgrades.

That said, if this game wasn't ending in a couple days I'd probably just code/run a simulation, because there should really only be one OPTIMAL upgrade path.