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

Fix failing cardio test and make sprinting distance less random #53950

Merged
merged 2 commits into from
Jan 2, 2022

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented Jan 1, 2022

Summary

Bugfixes "Fix failing cardio test and make sprinting distance less random"

Purpose of change

Test cases I added in #53603 were sometimes failing due to randomness in the stamina regen and movement code.

Describe the solution

  • Make stamina regen non-random - when regen is 19.4, always round up to 20.0 instead of only having a 40% chance of rounding up to 20.0 - that is, simply replace roll_remainder with std::ceil in the update_stamina function
  • Remove the random chance to become winded when below 20% of maximum stamina - instead, become winded only when stamina runs out - in the game::on_move_effects function
  • Adjust the test case for new expectations (some are 1 step higher than before)

Describe alternatives you've considered

Testing

Run tests/cata_test '[cardio]'

or many tests:

for i in {1..100}; do ./tst --rng-seed $i '[cardio]'; done

Additional context

Stamina regen: Use std::ceil instead of roll_remainder in
update_stamina. This ensures that the floating-point value is always
rounded up (instead of only randomly being rounded up), and should give
at most 1 extra point of stamina regen.

Getting winded: Before, there was a random chance to become winded below
20% of maximum stamina, meaning total running distance could be cut
short by 8-12 steps or more (effectively capping maximum stamina at 80%,
at random). Now, becoming winded is more predictable, occurring only
upon reaching 0 stamina.
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Jan 1, 2022
@Maleclypse Maleclypse added Mechanics: Character / Player Character / Player mechanics <Bugfix> This is a fix for a bug (or closes open issue) labels Jan 1, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 1, 2022
@wapcaplet wapcaplet added the Code: Tests Measurement, self-control, statistics, balancing. label Jan 2, 2022
- Adjust step expectations to match new deterministic stamina regen
- Separate [base] test case so it can be easily run by itself
- Capture turns as well as steps in running_steps
- Use can_run() for the loop condition
@wapcaplet wapcaplet marked this pull request as ready for review January 2, 2022 02:52
@kevingranade kevingranade merged commit e440d0e into CleverRaven:master Jan 2, 2022
@wapcaplet wapcaplet deleted the w-regen-not-rng branch January 2, 2022 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions Mechanics: Character / Player Character / Player mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants