angarg12 / nucleogenesis

Nucleogenesis JS incremental game
GNU General Public License v3.0
40 stars 21 forks source link

Balance of costs/production of tiers #103

Open angarg12 opened 7 years ago

angarg12 commented 7 years ago

With the addition of many new upgrades, we need to rebalance the cost and production of each tier to tune them down. My general idea is:

Players should end up owning less generators across the board, which is relevant for the new upgrades that rely on the number of generators owned.

angarg12 commented 7 years ago

As a follow up some initial ideas:

Increase price exponent to 1.15.

The decrease of price and power would be bigger for higher tiers.

For example, Tier 2 could lower the price from 100 to 80, 70 or 50, but Tier 10 could lower it from 7.5e10 to 7.5e6.

Would be best to run some simulations to make sure that no value is too off.

angarg12 commented 7 years ago

As follow up to #122 I'm going to write down my current sketch for a simulation to calculate price ranges.

First of all there are two different concepts: balance and pace. Balance is how each element performs compared to one another. Pace is the speed at which the game progresses.

We would like to balance the game, but if goals conflict we should probably favour the right pace for the game.

So, my first simulation idea would be to calculate the right range of upgrades prices that is balanced. What does balanced mean on this case?

An imbalanced generator or upgrade is one that is so bad or so good that it is never a choice: either you get it or not. For the purpose of a simulation we could measure how 'interesting' it's to buy an upgrade.

Take each generator and how much they produce, and rank them in order. For an upgrade to be interesting, it has to bump a generator to a higher rank. If it doesn't, it probably isn't very interesting.

Since this is a very complex problem we can make some fair assumptions. First, we can assume players buy all upgrades as soon as they have resources. Second, we can assume a simple buy strategy, where players buy 1 generator per second, and buy the one with the best price/production ratio. You can also limit generator purchases to 80% or 70% of current resources to simulate saving for an upgrade.

We also have a good guess of which upgrades are more powerful than others so that we can roughly order them e.g. x3 > x2.

With all of this in mind, I'm guessing it is feasible to run a simulation that, for each upgrade, gives a range of prices where it is 'interesting'. Beyond that, the hardest part would be to tie these prices up to pacing, for instance accounting for the fact that these upgrades are multiplicative and each one bumps the progression curve significantly.

HeinousTugboat commented 7 years ago

I'd like to propose we mark this for milestone 2.6.

HeinousTugboat commented 7 years ago

Ok, I'm gonna start working on adapting my sim script for this analysis. There's one thing I'm still missing, though. Where do you want to end up at the end of a given run? We can adjust pace and balance, absolutely, but I can't really compare the numbers unless I know what the end goal is.

So.. a pile of questions for pacing:

And for balance:

angarg12 commented 7 years ago

I'll write my ideas, please provide your feedback also.

First I would like to balance generators/upgrade prices not accounting for exotic prestige or dark prestige. This will give us at least a baseline that we can work on.

I consider up to dark matter and unlocking new elements early game. This gives us a few milestones. Players should see most of the major content and get familiar with it before this phase. That means players should see Helium decay, and I think that happens around 1e14 1H. Also players should have made exotic prestige quite a bit, get familiar with all the upgrades and exotic upgrades, and probably unlocked another major mechanic. I mention this because in the future I would like to make new mechanics (redox and reactions) cost eV. So lets say, if unlocking a new mechanic costs 1e6 eV, that would bump the total resources a couple of orders of magnitude higher, to 1e16 1H. By then players should understand how decay works, how eV and e- are global resources that persist through prestiges, how they can be used to buy other upgrades, etc.

In terms of time this should take 1-3 days, which I think should be enough to assimilate all the new gameplay elements.

In terms of number of runs, I'm not sure, but I would look at Realm Grinder. How many runs does it take for the first reincarnation? I haven't found any numbers.

Now to some specific questions.

I haven't worked too much on this, so feel free to experiment. All of this is guesswork anyway and we will need to playtest it ourselves to see how things actually feel.

HeinousTugboat commented 7 years ago

Looks like Realm Grinder takes about a week to get through the first reincarnation. However, their first reincarnation also takes place at 1e27 gems. I'd say 3 days until first void prestige is a pretty reasonable time frame.

I'd say over all it takes 10-20 prestige cycles to get to the first reincarnation on realm grinder, maybe longer depending on missteps. The bigger issue here, I think, is that they have a lot more content before reincarnation than we have before you unlock additional elements, and most of the mechanics there are actually unlocked in that first 1-3 days. So, I'll shoot for hitting ~1e16 H around the same time as, like, 5ish dark matter.

Ok, this gives me enough to work on. I'll start hacking at my script and update this thread with what I can come up with. Thanks!

HeinousTugboat commented 7 years ago

First I would like to balance generators/upgrade prices not accounting for exotic prestige or dark prestige.

So, I'm not sure this is at all possible, honestly. The problem is that if we don't want the runaway feedback loop, we have to balance it such that you can't actually achieve maximum production without them. It's such a tightly knit system that we have to at least have a baseline for exotic particles and prestige. For dark matter, though, I think we'll be fine for now just using it as a sort of vague goal. We can worry about specifics when we get there.

angarg12 commented 7 years ago

10-20 iterations sounds good. I was thinking about prestiging ~5 times a day, for 3 days makes 15, so we are in the same ballpark.

HeinousTugboat commented 7 years ago

Hokay. So, I wanted to touch base with you. It's been a busy week for me, but I haven't actually forgotten about you! I've spent a big chunk of this week completely rewriting my sim. I've increased its running speed a solid order of magnitude, and can run an entire week's worth of sim in about 7 seconds. I just now got to where I got the basic 2x upgrades working and all the math is playing together nicely.

So, I want to share my thoughts for the actual raw numbers.

For the Generators:

Gen Coeff Base Cost Base Power # at Void
I 1.12 10 1 300
II 1.12 100 5 275
III 1.12 1000 10 250
IV 1.12 1e4 25 225
V 1.13 1e5 50 200
VI 1.14 1e6 100 175
VII 1.14 1e7 250 150
VIII 1.14 1e8 500 125
IX 1.15 1e9 750 100
X 1.15 1e10 1000 100

So, this isn't random. I spent a lot of time fiddling with graphs and charts to try and get this fit a set of criteria, and so far I think they do so pretty well.

I spent a portion of this week building a idle producer test kit of sorts with Angular4, so I could just get a decent feel for how these numbers play out. It takes about an hour to get from Tier I to Tier V, and about an hour again to get to Tier VI. After a day, you should be around Tier VII, and after a week around Tier IX. This is without any upgrades. I spent a good portion of yesterday and today poking at the first set of upgrades, the x2 Multiplier. I think those should start at 1e5 for Tier I. There's naturally a long wait to get to Tier V at 1e5, and I think this would make that more compelling.

Interestingly, I just checked, and my Sim seems to be rather aggressive about it. Here's a chart of how long it waited between purchases:

image

Each new maximum corresponds to the sim buying the next upgrade. I've got the upgrade costs currently set to 1e5that tier's base power. I'll continue weaving the upgrades into it and eyeballing the costs. For now, I like the start and finish in terms of magnitudes. We can work on fitting the prices* of the upgrades to the timeline and pacing we want.

Let me know what you think. If you're curious about any of my implementation, you can see all of it here.

angarg12 commented 7 years ago

That's an excellent job, thanks a lot for your effort!

Looking good so far, I guess complexity will skyrocket with upgrades, particularly synergies.

I was thinking maybe x2 are too strong as an starter upgrade, that's why they need to be more expensive. Comparatively boosts are much weaker and could be introduced earlier. How does it sound to make these the starter upgrades and gate the multipliers as exotic upgrades?

HeinousTugboat commented 6 years ago

Just did a quick check of the different choices, I set the boost equal to 1e5*generator, 1e7, 1e9 and 1e11*generator. I agree, I think we should unlock boosts first and have the multipliers be an exotic upgrade. I'll go with that for now. Here's what that looks like:

image

angarg12 commented 6 years ago

So I also wanted to give an update on this.

Balancing is hard, because there are so many numbers and dependencies. I wondered if we could use a learning algorithm to help us with this one.

First I tried neural networks, but I couldn't find a way to relate the bot and simulation with the learning function.

Then I tried genetic algorithms. I managed to hack together some code that creates a set of generators that fit some goal in the simulation.

https://gist.github.com/angarg12/374a22770babbdf87912e0b26c42df4f

In random_chromo we create new 'chromosome', which is just a set of data. On this case we generate 10 generators, only the price and power. The advantage here is that we can impose any restriction we want. For instance, prices and power are increasing, and power is always lower than price.

In mutation and crossover we randomly change datasets. The point here is that we have to make sure that the restrictions we put in place are enforced.

The fitness function is where learning happens. Here we would run the bot with each dataset, and then compare the output with whatever goal we want to achieve. On this example, I run a simple simulation for 1 hour, and then compare how far from 1e7 resources the outcome is.

So after running this algorithm you get as an output a dataset that after running for 1 hour gets as close as 1e7 as possible. This is one example output:

Pairs [price, power] for 10 generators [[15, 1], [18, 9], [21, 13], [24, 21], [33, 24], [82, 68], [183, 149], [339, 284], [1345, 589], [6459, 2588]]

The algorithm is not very smart, it produces prices that are very close, and powers which are too high. Nevertheless, they meet the goal that we set, and this algorithm is as good as the fitness function.

The fitness function could be improve to track many more parameters. Maximise how often the top generator changes, adapt the number of generators of each tier to a certain shape, purchase upgrades close to certain intervals... honestly I don't know if this would produce interesting results or just be a waste of time.

Nevertheless it was a fun exercise to play around with this. Feel free to check it out if you think it could help to iterate faster on adjusting prices.

HeinousTugboat commented 6 years ago

Hi! So, I've been spending a lot of time at a computer where I don't have access to node, so I'm only able to make any progress using essentially straight javascript. I spent a lot of time this past week working on getting Angular 4 to run in browser without any sort of local transpiler, and then proceeded to build my entire sim into, well, basically a cut down version of the game. Since I already had the CSS from that other prototype I showed you, I just used that. I added in the same basic buying routines I use in the sim, and pretty much just lifted all of my model files from the sim wholesale. I spent a lot of time this week more or less just watching it go, and seeing how the timeframes feel. I think the numbers I gave before should work pretty well. As of right now I'm not including any prestige-gating of upgrades. That's my next goal, that'll allow us to extend the entry period. The actual upgrade prices all still need adjusted, too.

Another thing, I actually adjusted the exotic prestige production bonus. I'm not sure whether it should stay at a flat 0.001%, but I added a diminishing return to it that's still pretty high and probably won't be particularly noticeable, but will cap any runaway income like we were seeing before in #104.

Here's that equation: image

Oh, another thing that was slowing me down a lot was I spent the week transitioning to new hosting. As fun as that is, it's a serious pain. :-D

Anyway, here's my sim. All of the code behind it is in this repository. Since it's a completely different stack, I didn't want to just plop it on yet another branch. In the Lab tab are the various options I've implemented so far. The biggest one is the Autobuy toggle, it's pretty self explanatory. If you want to prestige, you'll have to go to that tab to do so. Upgrades are on the card's upgrades tab, and the lab tab shows every upgrade loaded into the game, colored depending whether it's available for purchase or purchased. I also have a soft-limit on upgrades that they won't even display unless your total earned is at least half the cost of the upgrade. I don't see much reason to be polluting the upgrade list with things multiple orders of magnitude more expensive than what the player can reasonably afford.

Alright, let me know what you think. My next steps are going to be gating the upgrades properly and implementing prestige upgrades. I also want to add the ability to tweak values in the Lab tab so we can get a feel for the different pacings. Oh, and I've got the gameloop set up such that it can run at basically whatever speed you want. I'm going to add a slider so we can crank it up from 100ms/s up to a minute/s+. Could probably even do an hour/s, but I think the autobuy script would basically stop functioning at that point.

If you have any questions or suggestions, don't hesitate to let me know.

angarg12 commented 6 years ago

Wow, that's a lot of work right there! Thank you very much for putting this together.

Indeed this week I have been brainstorming a lot (you can see I changed a couple of things around) and came up with a couple of issues that affect this task.

First, I also notice the problem with exotic production. I was playing with big numbers and then noticed that exotic matter gets out of control pretty quickly. Because of the formula, it is always a few orders of magnitude below your matter, so if you get something like 1e40 matter, you get 1e32 exotic matter.

I love the shape of the curve and it produces exactly what I wanted, but these numbers may be problematic. For one thing, it makes balancing a pain since it grows so fast. Second, it sort of removes the feeling of exotic matter being important.

This is the formula. The 10e7 is what makes exotic matter to be 7 orders of magnitude below matter. I was thinking about making that number grow so it dampens production. I don't have a clear idea of the target, but definitely much lower than now. Something around 1e30 or 1e40 exotic matter for 1e300 matter, that should give us much more manageable numbers in the range of early game (in the thousands at most, probably). Would be good to set this up before calculating the price of exotic upgrades.

Second, right now the most expensive upgrade tops at 3.75e+25 price, but in the mid/end game numbers should go way higher. This means that upgrades should be spread out much further so that progression continues for longer. But it also means that probably more upgrades should be included.

That brings me to another point. Right now each category of upgrades has only 1, e.g. one x2 bonus, one x3 bonus, etc. But it doesn't need to be that way. We could easily have five x2 and x3 bonuses alternating and spread out in price. In sequence, it would look something like x2, x2, x3, x2, x3, x2, x4, x3... Just by doing that you can easily extend the range of prices from 1e25 to 1e125.

On the flip side, as usual, the more upgrades, the harder it is to pace and balance. I see two ways to mitigate this. First, if we figure out a general formula to price upgrades, it should be generally easy to plug in new upgrades. Second, my main aim is to make early game as tight as possible, and I am not so concerned with middle/late game at the moment. Early game is where most people drops the game now, and it should cover until when you buy your second element. In terms of resources, that should be around 1e12~1e13. As long as that part of the game is properly balanced and pace, is a good start.

HeinousTugboat commented 6 years ago

So, two things. First, the upgrades and everything I've got set up right now as balanced should land you right around 1e12 - 1e13/second. The target was to be able to get 1e16 matter in 1 hour, enough to start decaying 3H into He, and with the equations I've been using, enough to get you one or two dark matter.

I understand what you mean about adding more upgrades, but I don't really see why. Once you get to the end of an element, they're all more or less the same. There's not really any good reason to accumulate that much matter in the majority of the elements. The only real exception would be the exceptionally slow to decay ones. What elements would take the longest to decay? We should balance the end-end game around those. I don't see much of a good reason to just keep going after that.

angarg12 commented 6 years ago

The longest half life isotopes are about 1e31~1e32 so that should be the maximum production for a single element. But if you consider decay chains, then it becomes more interesting.

Let's say you have A, B and C. A decays to B in 1e20 and B decays to C in 1e20. If you get 1e40 A, then you would get enough B to start decaying into C.

Obviously in mid game we want players to focus in playing different elements, combinations and exotic matter. And that brings the point that I brought up in #128. If we include more exotic upgrades in the higher end of the price range, players need to produce more matter to access them.

Lastly there is the point of progression and game feel. Of course this is only my opinion, but I guess that if the basic game progression stalls after early game, players won't feel too well about it.

Ultimately more upgrades and longer progression may be slightly harder to balance, but that is essentially the only downside. Once it is in place you get player engagement for free.