ErikMcClure / PonyClicker

Pony Clicker, a new way to waste time on your computer, now with ponies!
MIT License
58 stars 26 forks source link

Pony Clicker Analysis #74

Closed ErikMcClure closed 8 years ago

ErikMcClure commented 9 years ago

I have developed a very primitive analysis of Pony Clicker's gameplay using an automated buying mechanism which is now available in the master development branch under utilities/analysis.html. I re-organized ponyclicker.js so that all code with DOM side-effects is now at the bottom of the page, under a if(disable_ponyclicker) statement. I also had the ponyclicker JS file return a few basic public objects. This allows the analysis page to load up the game logic without loading the game itself.

The game simulator works by selecting an optimal building purchase, then fast-forwarding time to the exact moment at which it can buy it, then selecting another building purchase, and repeating. The optimal playing algorithm should be:

  1. Find building with lowest per +1 SPS cost. This is the target building.
  2. Look for other buildings that can be bought before the target building, and whose SPS bonus result in a reduced time-to-buy for the target building that exceeds the amount of time lost by purchasing that building instead.
  3. If such buildings exist, set the target building to the one that results in the greatest time reduction.
  4. Buy the building when it becomes available, go back to step 1.

I attempted to implement steps 2 and 3, but it didn't seem to work and it doesn't make enough of a difference to bother with right now. Simply following step 1 repeatedly seems to produce a reasonable playthrough all by itself. The algorithm skips the very start of the game by starting at 100 smiles and going from there. It also has special handling for when it wants to buy a friendship, but can't - it will attempt to buy a pony instead.

Currently, at precisely 101 steps, this happens:

pony clicker analysis

It seems abundantly obvious that the moment a grand galloping gala becomes available, the entire game begins to fall apart. The SPS curve completely explodes once anything with a 2^P is purchased, to an almost hilarious degree:

ponyclickercurve

Currently, this page uses Google Charts, because I needed to get this up and running as soon as possible. Even with this comparatively primitive analysis of pony clicker, it has already demonstrated precisely where the game unravels, which will be instrumental in rebalancing it to something more sane. A properly balanced game will have a smooth SPS curve and a time-to-buy delta average that increases very slowly over the course of the game.

In the future, I'd like this page to incorporate buying upgrades and highlighting where upgrades get bought, as well as showing where certain store-based or smile-based achievements would be earned in a master timeline. Ideally, it should display the SPS generation algorithms and cost curves of each store item, as well as the governing SPS ratio curve in editable text fields that dynamically update the graphs when they are changed to facilitate analyzing new formulas. In a perfect world, I would build a customized master timeline graph using D3.js, but this is nontrivial and very time consuming, so for right now, Google charts will do.

I will be actively updating this analysis page as I add more graphs in an effort to settle on a gameplay experience that isn't completely broken. I do not expect this to be finished in time for v1.0. The v1.0 release only needs to un-break the late game and make it at least not completely stupid. Given how utterly broken the game is right now, simply selecting subexponential functions will likely suffice. I want to continue developing this analysis page well past v1.0 so the game curve can be carefully tweaked as time goes on. It will also allow us to test new features and ensure they don't make something violently blow up.

Abion47 commented 9 years ago

I'd be curious to see where your analysis page goes if you let it run further.

I'm sitting at 26 Ponies, 307 Friendships, 310 Recitals, 276 Parties, 240 Parades, 214 Concerts, 200 Festivals, 181 Raves, 161 GGGs, 125 Coronations, 105 National Holidays, and 93 Elements. On top of that, I have 21/21 upgrades and 209 muffins. This is sitting me at +36.24 octillion SPS, which sounds like a lot, but upgrading any further seems impossible to do in any amount of time.

Every upgrade of the Elements gives me septillions of SPS for decillions of smiles, and the Holidays and Friendships give me quadrillions of SPS for tens of nonillions. Everything else is labeled under the ambiguous but very clear label of "almost nothing". The only thing I can upgrade that will give me significant gains are Ponies, but the next one costs 10.5 decillion, which would take days to achieve at the speed I am currently stuck at. To make matters worse, when at some point I actually am able to get it, it will only increase my SPS by shy of a nonillion, which has limited usefulness when everything is costing me hundreds of nonillions or more and increases greatly on every purchase. I shudder to think how much the next pony will cost.

There is definitely a drastic pattern of diminishing returns currently in the game. The only apparent strategy has been to try and get muffins from the building mile marks, as that increases my SPS by a percentage rather than by a flat amount that ranges from laughably insignificant to utterly useless. But I have reached a point where the buildings are prohibitively expensive without increasing my SPS by any margin that is even noticeable. The next closest batch of muffins would be the 200 Raves mark, but I am still 19 Raves away from achieving it, and when the next rave costs almost 400 nonillion which will take me nearly 3 hours to get, I feel like I could easily be weeks away from seeing a single new muffin.

This happened on the v0.88 patch. Before then, I was sitting at a comfortable increase in scale. Once that patch hit, my SPS fell by several orders of magnitude, and I literally couldn't afford anything. At v0.89, the prices of buildings fell a bit so I was at least able to do something, but the overall damage is still there.

ErikMcClure commented 9 years ago

Letting the analysis run further results in a violent explosion, where almost everything stops making sense and the entire early game is blown to pieces. The graph basically turns into an L shape that you see in the second image, where the exponential growth is so ridiculously enormous you can't tell what's going on anymore.

The v0.88 patch fixed upgrades, which meant that muffin bonuses to SPS were no longer multiplicative, which drastically reduced SPS. The muffin bonuses, however, are keyed off of achievements, which meant they were simply staving off the inevitable, which was the outpacing of the cost function from the SPS function.

I am currently looking into a drastically reduced SPS generation function focused on specific building synergies instead of exponential growth functions that simply get out of hand.

Abion47 commented 9 years ago

I'm curious to know what that point of explosion in the data would look like on a logarithmic scale.

ErikMcClure commented 9 years ago

Estimated SPS of each individual building, by number of friendships owned, on a LOGARITHMIC SCALE

logscale

Yes, the elements of harmony are twice as many orders of magnitude more powerful than the national holidays, which in turn are twice as many orders of magnitude as grand galloping galas. It becomes obvious where everything else stops being useful, and you can see the upticks caused by each bought pony in the graph.

Needless to say, the late game buildings are utterly broken. This graph has been committed to master if anyone wants to play around with it.

Abion47 commented 9 years ago

Yeah, that pretty much reflects exactly what I've been seeing in the game myself. Though one thing I feel like I have to add is that while there are points in every building's life where the previous ones become hopelessly obsolete (particularly in regards to the final three buildings), there also seems to be a point where the cost of a building far outweighs its benefits. To that end, other graphs I might suggest that could be helpful in terms of balance-finding would be ones illustrating SPS with respect to cost, or the ratio of SPS over cost with respect to quantity.

Abion47 commented 9 years ago

It seems to me like, with that graph in mind, it's basically impossible to balance exponential gains with linear gains. That makes sense, though, since there only seems to be three ways of handling the situation as is.

The first two: 1] make the linear building a cheap early building, or 2] ramp up the slope of the linear function to crazy amounts to compensate. The problem of the first is that it makes the building quickly obsolete, and the problem of the second is that at early quantities it can easily be insanely overpowered - and a problem they both share is that, no matter what, an exponential function will catch up to both of them eventually and will quickly surpass them once it does.

Then the third is to design some kind of "smart" linear function that alters its benefits to dynamically match up with the exponential function's growth... but at that point the linear function is basically acting like an exponential function anyway.

So really, there's only two solutions to this problem in regards to the late game. Either all the buildings have to have exponential benefits, or none of them can.

ErikMcClure commented 9 years ago

Progress on balancing the game:

balancing

The route i'm trying to go with this rebalance is that each building gets bonuses from certain previous buildings. Roughly speaking, this means each tier adds another multiplicative term on to the equation, which seems to do a good job of not uncontrollably blowing up. The building equations right now look something like this:

  1. 0
  2. 1
  3. P
  4. F
  5. P+F
  6. P+F+A+B+C
  7. P*F
  8. PFD
  9. PF(B+C)
  10. PFD*M
  11. PFCEG
  12. PFABD

Where P = ponies, F = friends, and A, B, C, etc. denote recitals, parties, etc. This is all without upgrades. At the moment there are dips in the CPS curve that are causing frequent buying sprees after a given building is purchased that I'd like to do something about. It's not clear whether the fundamental curves should be altered, or if upgrades should be introduced to slightly modify the curves at specific points to try and stave off "building buyout starvation" which can be seen in the massive spikes in the Time To Buy graph, which represent a much more powerful building becoming the ideal buyout, but without sufficient SPS allowing it to be bought for a significant period of time.

This does a nice job of stabilizing late game without allowing anything to absolutely dominate (as far as I can tell), but as expected, the cost functions eventually outrun the SPS increase and the graph starts leveling out in extreme lategame with no upgrades to push it forward:

balancing2

Thus with no upgrades, you will never get more than about 20 to 21 ponies and your SPS levels out at 10 trillion per second. I suggest introducing a late-game upgrade that normalizes the SPS growth rate of all buildings to match their cost increase, which would keep the SPS steadily climbing - even then, eventually we would encourage players to do a soft reset.

ErikMcClure commented 9 years ago

After throwing around ideas and some more experimentation, I landed on this formulation:

8872d25e-0254-11e5-9647-1c323039b349

This transforms the Elements of Harmony into a superpolynomial function based on both buildings and friendships, which in turn forces everything to remain relevant through the late game, because buying anything will fuel the superpolynomial expression. However, the time-to-buy still increases steadily, so by the time you get to late game everything starts taking forever. Fundamentally, however, we do not get a tapering off - the SMS can theoretically increase at a linear rate, just very slowly.

This seems like the best approach for the base building SPS formulas. Now it's just a matter of tweaking things for balance and then adding upgrades to lengthen the effective SPS curve.

ErikMcClure commented 9 years ago

It turns out that upgrades were completely broken. How broken? This broken:

brokenupgrades

After incorporating upgrades into the optimal play algorithm, it became immediately obvious that they were insanely overpowered. To preserve the curve, I have drastically increased the prices of both friendship and muffin upgrades. Additional upgrades will be utilized later on to boost the curve to allow for higher SPS ratios.

torrentails commented 9 years ago

Just a humble suggestion, when you do implement a soft reset feature, I recommend simply calling it "September"

ErikMcClure commented 9 years ago

"September"

You sly pony, you.

torrentails commented 9 years ago

Ha ha, I was actually referencing the LTS/Mic song, ie. the soft reset being when every pony died, but that works well too; either way, the name fits!

ErikMcClure commented 9 years ago

I think i'm going to call it "New Season" but I can make one of the achievements "September"

Abion47 commented 9 years ago

If you soft reset after the Pinkiepocalypse starts but before it ends? Or if you sell all your ponies after getting a certain number of them (say, 20)?

ErikMcClure commented 9 years ago

You can't sell ponies, and the pinkiepocalypse is a perpetual endgame state that is triggered. It doesn't end, so it's expected that you will soft reset in the middle of it.