Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix float-keying activity level problem (#49179)
* Activity diary test now detects float-keying problem avatar::log_activity_level is now getting fed (floating-point) numbers that don't match the exact activity levels, due to #45316 making the activity level per-turn then averaging activity over each 5-minute period. The activity diary test (in tests/char_biometrics_test.cpp) was not spotting this since it was still using times in multiples of 5 minutes. This commit moves around 1 minute of NO_EXERCISE, keeping the same total number of minutes of each activity level. Currently, this results in a test failure in which 1 5-minute interval is missing from each of the activity levels in the diary, since those 5-minute intervals were at intermediate (averaged) levels of activity. * Process intermediate activity levels for debug output This "buckets" activity levels that aren't exactly the predefined set of levels (due to averaging over 5 minutes) into the closest predefined level in avatar::total_daily_calories_string. Note that saving of levels will not be bucketed. This, while useful for close inspection of intermediate levels via looking at the save file, will make the file slightly larger, slower to input/output, and (even) harder to read manually. However, this has been true since #45316 was merged and nobody seems to have noticed it. * Correct logic error in attempted fix. I forgot to add the number of 5-minute intervals and was instead adding just one. It still doesn't quite work right (and I'll need to adjust the expected gained/spent/total caloric values), but it's a lot closer. * Adjust expected numbers for mixed intervals The new results in terms of minutes are actually now correct; the difference is because the last 5 minutes are 4 minutes of EXTRA_EXERCISE and 1 minute of NO_EXERCISE, which averages out to ACTIVE_EXERCISE (410 + 11 = 41; /5 = 8.2, and ACTIVE_EXERCISE = 8.0). The rest is likely roundoff error, although it still bothers me a bit. Co-authored-by: actual-nh <[email protected]>
- Loading branch information