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

Rework stat calculation to use interval arithmetic #820

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

gdavid04
Copy link
Contributor

@gdavid04 gdavid04 commented Mar 11, 2025

Replaces the limited constants system used for cost and spell stat calculation with interval arithmetic.

This means

  • piece costs no longer have to be monotonically increasing as the absolute value of a constant input increases
  • arbitrary intervals are supported as opposed to just -c<x<0 and 0<x<c with Constant Wrapper
  • in some cases, Constant Wrapper is no longer needed
  • even where Constant Wrapper is needed it doesn't have to be at the end of the calculation
  • the interval API is more extensible, making it easier to adapt to other types as well, e.g. vectors with bounds on length and components, entity lists with bounded size or any type added by addons

This is a breaking change and most addons will have to make changes to be compatible.
This should be fully backward compatible with older spells.

Closes #665

TODO

  • take Error Catcher into account when calculating the interval for its target
  • make interval checks more lenient so Constant Wrapper is needed less often, e.g. make Trick: Sleep accept [-a;+b] intervals as well, only showing an error for negative values at runtime in this case (interval arithmetic can often give much larger bounds than needed)
  • improve interval calculation for some operators
  • remove in-game references to constant values

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.

Constant: Wrapper Not able to emulate values between -1 and 1
1 participant