Optimal Efficiency Starforce Calculator for Maplestory
Back to Portfolio: https://devoreni.github.io/portfolio/
GitHub Project Link: https://github.com/devoreni/Theoretical-SF-cost-calculator
Background
What is Starforce?
Starforce is a system in the game MapleStory that allows players to enhance equipment, such as weapons and armor, by adding stars. Each star increases the item’s stats, making it stronger. However, the process is costly, risky, and influenced by many factors.
Basics of Starforce Enhancement
- Starting Point: Items begin with 0 stars.
- Goal: Players aim to add stars, up to a maximum of 25.
- Costs: Each attempt costs mesos (in-game currency). Costs increase with item level and current star count.
- Outcomes:
- Success: The item gains a star.
- Failure: The attempt fails, and the item may lose a star.
- Destruction: At certain star levels, failure may destroy the item unless special protections are used (at an additional cost).
Cost Complexity
The system introduces several layers of complexity:
- Destruction Penalty: Destroyed items revert to 12 stars and require another item to restore them.
- Success, Failure, and Destruction Rates:
- Star Catching: Improves success rates and reduces failure rates.
- 5/10/15 Events: Guarantee success at the 5th, 10th, and 15th stars.
- “Safe” Stars: At 15 and 20 stars, items won’t lose stars on failure, though destruction is still possible.
- Chance Time: Guarantees a single success after two consecutive failures where the item is not destroyed.
- Safeguarding: Prevents destruction at the 15th and 16th stars, but at an increased cost.
- Enhancement Costs: Determined by item level and star count, with adjustments for:
- MVP Bonus: Discounts based on real-money purchases.
- 30% Off Events: Reduces costs by 30%.
- Safeguarding Fee: Adds the full base cost to the enhancement fee.
- +2 Stars Event: Grants an extra star (up to 10 stars) without cost.
For more on the Starforce system, see this guide.
The Problem
Current online Starforce calculators rely on simulations that:
- Take significant time, especially for higher star counts.
- Produce variable results, offering only rough estimates.
- Struggle with stars above 22 due to extreme difficulty and variance.
I aimed to address these limitations with a tool that is fast, accurate, and capable of handling all star levels.
Solution
After a month of development, I created a solution leveraging mathematical, statistical, and computational techniques. All equations were developed independently for this project.
Destruction Costs
Destruction requires accounting for the cumulative cost of reverting to 12 stars and re-enhancing. I used a bottom-up dynamic programming approach, starting from the lowest reachable star (0-12 depending on conditions).
Enhancement Cost Calculation
The cost is calculated as: \[
C = b \cdot (M + s)
\] Where:
- ( C ): Enhancement cost
- ( b ): Base cost (from the strategy guide)
- ( M ): Discount factor
- ( s ): Safeguard cost multiplier (0 without safeguarding, 1 with safeguarding)
Discount factor ( M ): \[
M = 1 - t - m
\] Where:
- ( t ): 30% event discount (0.3 if active)
- ( m ): MVP bonus (0 to 0.1 based on spending)
+2 Stars Event
If the current star is ≤10, the calculator skips the cost of the next star and adds one extra star.
Expected Cost Calculation
The core calculation involves finding the expected cost to reach the next star. This includes all possible outcomes, weighted by their probabilities: \[
E_{n+1} = \frac{C_n + f_{k_n}C_{n-1} + f_{k_n}f_{k_{n-1}}(C_{n-2} + E_n) + (f_{k_n} + f_{k_{n-1}} + f_{d_n}) \sum_{i=13}^n E_i}{s}
\] Where:
- ( E ): Expected cost for star ( n+1 )
- ( C ): Enhancement cost
- ( f_k ): Failure (lose star) probability
- ( f_d ): Destruction probability
- ( s ): Success probability
Dynamic programming optimizes performance by reusing prior results.
Expected Destruction Count
To calculate expected item destructions, a similar equation is used: \[ B_{n+1} = \frac{f_{k_n}f_{k_{n-1}}B_n + \left(1 + \sum_{i=16}^n B_i\right)f_{k_n}f_{d_{n-1}} + f_{d_n}}{s} \] Where ( B ) represents the expected number of destructions at star ( n+1 ).
Destruction Distribution
Destruction likelihood follows a geometric distribution. The probability of avoiding destruction from one star to the next: \[ P_{n+1} = \frac{s}{s + f_{d_n} + f_{k_n}f_{k_{n-1}}(1 - P_n) + f_{k_n}f_{d_{n-1}}} \] Then, using the next formula, the cumulative probability gives the chance of no distruction from the starting to target star. \[ T = \Pi_{i=j}^nP_i \] - ( j ): starting star - ( n ): target star
Then, using probability T, players can use a geometric distribution to estimate spare items needed.
User Interface
To simplify use, I created a GUI with Tkinter. It allows users to input parameters and calculate results efficiently, avoiding command-line complexity.
Results
The calculator delivers precise, consistent values for costs, expected destructions, and destruction probabilities. Below is the GUI with a sample calculation:
Speed Comparison
The table below compares the time required for a single simulation versus my program:
Target Star | Simulation Time (ms) | Calculation Time (ms) |
---|---|---|
22 | 3 | 0.16 |
23 | 8 | 0.24 |
24 | 270 | 0.20 |
25 | 30,000 | 0.26 |
Simulations for statistical accuracy generally require 15,000 samples due to the high variance of starforcing, further highlighting the efficiency of my program.
You can find detailed instructions in the GitHub README, along with a downloadable .exe
file. The source code is well-documented for those interested in exploring the implementation.