Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I’m growing cellular recreation and I’m caught on a difficulty concerning correct participant stats scaling based mostly on stage.

As a parameters for the computation we now have:

  • base XP worth
  • a number of increment values (for instance one increment for ranges 1-5, one other one for 6-10 and so forth…)

We’re utilizing this formulation:
present stage XP = earlier Stage XP + (earlier stage XP ^ increment).

Let’s break it down on an instance:
We need to get the XP threshold to graduate from stage 3. The bottom XP worth is 100, increment for ranges 1-5 is 0.5.

To get the wanted XP, we first have to get the worth for stage 2:

level2Value = 100 + 100^0.5

Now we now have stat worth for stage 2 and we’re capable of get level3Value like this:

level3Value = level2Value + level2Value^0.5.

If we needed to calculate values for some excessive ranges, this looks as if a reasonably inefficient solution to do issues, as values for all earlier ranges have to be computed prior, and as well as we’re altering the increment worth based mostly on stage – we can’t easy have one line of formulation which will get us the quantity that we wan; all relies on earlier values.

In fact we are able to compute all earlier values, cache it on the server after which do the lookup to the information, however we want to keep away from it if potential – nonetheless I’ve a sense that there have to be higher solution to cope with this downside.

My query is the next:

Are you able to recommend another (related) formulation or methods to compute this? Ideally only one line of code ought to do the trick (one thing like `stage X XP = X * baseXp * increment|, however extra advanced which permits utilization of various increment values)

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *