Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: experience calculation efficiency and increase level cap #2631

Merged
merged 5 commits into from
Jun 1, 2024

Conversation

omarcopires
Copy link
Contributor

@omarcopires omarcopires commented May 14, 2024

This pull request proposes a significant optimization in the experience calculation formula for the game Tibia. The new implementation brings several advantages in terms of performance and accuracy of the results.

  1. Calculation Optimization:
  • The original formula has been simplified, reducing the number of multiplications required to calculate experience.
  • The new formula is designed to be more efficient, resulting in overall faster performance during experience calculation for each level.
  1. Reduction of Overflow:
  • With the decrease in the number of multiplications, the new formula significantly minimizes the occurrence of overflow, especially at higher levels.
  • This results in a more stable and accurate gaming experience, allowing players to reach higher levels without encountering artificial limitations.
  1. Expansion of Level Cap:
  • Thanks to the efficiency of the new formula, players can now reach a maximum level of 1,034,406, compared to the previous limit of 717,217 with the old formula.
  • This significantly expands the possibilities of progression in the game, providing players with a more challenging and rewarding goal.
  1. Details of Changes:

Lua:

  • The getExpForLevel function has been modified to use the new simplified formula.
  • Now, experience calculation is performed more directly and efficiently, without compromising the accuracy of the results.

C++:

  • The getExpForLevel function has been updated to accept and return uint64_t, ensuring compatibility and precision for higher level values.
  • The new formula is implemented to optimize performance and stability during experience calculation.
  1. Expected Impact:
  • Significant improvements in game performance, especially during experience calculation for each level.
  • Reduction in the occurrence of overflow, providing a more stable and accurate gaming experience.
  • Expansion of the level cap, challenging players to reach new levels of progression.

These changes have been carefully tested and reviewed to ensure their integrity and effectiveness. We hope that this optimization positively contributes to the player experience in Tibia.

@un000000
Copy link
Contributor

@omarcopires The title is misleading, as formula is correct (algebraically). You should change pull name, so it indicates problem with overflow, not formula itself.

@omarcopires omarcopires changed the title fix: experience formula enhance experience calculation efficiency and increase level cap May 16, 2024
src/creatures/players/player.hpp Outdated Show resolved Hide resolved
@omarcopires omarcopires requested a review from dudantas May 18, 2024 23:09
@Chapeleiiro
Copy link
Contributor

Could you also remove the limit on skills? There is no longer a need for it

@omarcopires
Copy link
Contributor Author

Could you also remove the limit on skills? There is no longer a need for it

You need to check and find out what the current limit is, I believe it's not that simple!

@elsongabriel elsongabriel changed the title enhance experience calculation efficiency and increase level cap refactor: experience calculation efficiency and increase level cap Jun 1, 2024
@elsongabriel
Copy link
Contributor

Following my tests and gpt checks, both formulas return the same result, so everything is fine.

@elsongabriel elsongabriel merged commit 7e7a610 into opentibiabr:main Jun 1, 2024
29 checks passed
@omarcopires omarcopires deleted the fix-exp-formula branch June 3, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants