Skip to content

Add tests for index stat progression calculation#129

Closed
Copilot wants to merge 18 commits intomainfrom
copilot/add-index-stat-progress-tests
Closed

Add tests for index stat progression calculation#129
Copilot wants to merge 18 commits intomainfrom
copilot/add-index-stat-progress-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 4, 2026

  • Analyze existing test structure and progression calculations
  • Design test cases with clear mathematical explanations
  • Implement new top-level test for index stat progression
  • Add subtest for success cases with multiple test scenarios
  • Cover edge cases (no final deaths, no exp progress, etc.)
  • Verify tests fail as expected (feature not implemented)
  • Address PR feedback: restructure test data, improve assertions
  • Fix test cases to use integer stars with real star calculation
  • Simplify durations and rates to use simple integers and fractions
  • Add discriminant expectations to all test cases with coverage of positive, zero, and negative discriminants
  • Add cubic coefficient validations (a, b, c, d) with comprehensive coverage of sign combinations
Original prompt

Add tests for index stat progression calculation. This is not implemented yet, so the new tests will fail, but that is okay.
Create a single new top level test in the progression tests file. Under this create a single subtest for the success cases. This test will just define a set of cases, and run these cases in subtests in a for loop.
The cases should define exactly the start stats, the end stats, the duration (in days) between these two, the expected days until milestone, milestone, index, and progress per day. The stats should be a simple object with just experience, final kills and final deaths. Group the expected values in a simple object "expected".
The test should destruct the result and do a deep strict equal with the expected result. It should then do a "close enough" check on the floats (e.g. within 1e-6).
Create a variety of cases covering different normal scenarios and edge cases (no final deaths, no exp progress, etc)
Make sure the cases have number that are simple to work with (preferably small integers) and that a thorough explanation has been given behind the math behind each test case and expected value.
Note that we will average out stars to (total exp for 100 stars / 100) instead of working with the different exp requirements for the early stats vs the rest when considering progression. The current expected index will use the actual exp -> star calculation however.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Jan 4, 2026

Deploying rainbow with  Cloudflare Pages  Cloudflare Pages

Latest commit: ccc5165
Status: ✅  Deploy successful!
Preview URL: https://5a33abf4.rainbow-ctx.pages.dev
Branch Preview URL: https://copilot-add-index-stat-progr.rainbow-ctx.pages.dev

View logs

Copilot AI changed the title [WIP] Add tests for index stat progression calculation Add tests for index stat progression calculation Jan 4, 2026
Copilot AI requested a review from Amund211 January 4, 2026 21:45
Comment on lines +1149 to +1159
durationDays: number;
startStats: {
experience: number;
finalKills: number;
finalDeaths: number;
};
endStats: {
experience: number;
finalKills: number;
finalDeaths: number;
};
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move duration days and start and end stats into an object called trackingStats, remove the stats suffix on start and end since they are now scoped @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3a38d8d. Moved durationDays, start, and end into trackingStats object and removed Stats suffix.

Comment on lines +1459 to +1466
// Exact checks for simple values
assert.strictEqual(nextMilestoneValue, c.expected.milestone);

// "Close enough" checks for floats (within 1e-6)
assert.ok(
Math.abs(endValue - c.expected.index) < 1e-6,
`endValue ${endValue.toString()} should be close to ${c.expected.index.toString()}`,
);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot move endvalue and next milestone back into the result object. We can make sure these are nice numbers that don't need float comparison when setting up the tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3a38d8d. Moved endValue and nextMilestoneValue back into the main assertion object.

// Deep strict equal on the rest
assert.deepStrictEqual(rest, {
stat: "index",
trendingUpward: true,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot set trendingupward to milestone >= endvalue in the test assertion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3a38d8d. Set trendingUpward to milestone >= endValue in the assertion.

Copy link
Copy Markdown
Owner

@Amund211 Amund211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the average exp per star should only be used for progression calculations (e.g. it should estimate that going from 57->58 should take 4870 exp. The actual star value at the end stat should use the real star calculation e.g. 500 exp -> 1 star, etc. these values are encoded in the star calculation function exptostar or something like that.

Fix the test cases to have integer stars at the end stats, while keeping the same difference between start and end to keep the progression the same. If this is impossible (due to low exp) you can either shorten the duration to keep the same progression, or change the test cases by changing the end star

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot the average exp per star should only be used for progression calculations (e.g. it should estimate that going from 57->58 should take 4870 exp. The actual star value at the end stat should us...

Done in 3ed5042. Updated all test cases to use integer stars at end stats:

  • Use real star calculation (bedwarsLevelFromExp) for actual end index values
  • Keep average exp/star (4870) only for progression calculations (milestone ETA)
  • Adjusted experience values: 500 exp (1 star), 7000 exp (4 stars), 524000 exp (110 stars)
  • Modified durations and kill/death stats to maintain similar progression rates

Copilot AI requested a review from Amund211 January 5, 2026 14:37
@Amund211
Copy link
Copy Markdown
Owner

Amund211 commented Jan 5, 2026

@copilot in the previous commit some the tracking stats duration were changed to awkward numbers to fix the star calculation. Revert this change and follow the instructions below again, but this time prefer simple integers for most coefficients. The days until milestone and progress per day values will likely not be integers, but we can force the current index, current star, to be integers, exp per day to be some simple (integer or simple fraction) multiple of 4870 exp, and final kills/ deaths per day to be integer or a simple fraction.

the average exp per star should only be used for progression calculations (e.g. it should estimate that going from 57->58 should take 4870 exp. The actual star value at the end stat should use the real star calculation e.g. 500 exp -> 1 star, etc. these values are encoded in the star calculation function exptostar or something like that.
Fix the test cases to have integer stars at the end stats, while keeping the same difference between start and end to keep the progression the same. If this is impossible (due to low exp) you can either shorten the duration to keep the same progression, or change the test cases by changing the end star

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

...

Done in a3a78b2. Simplified test cases with cleaner numbers:

  • Durations: 10, 10, 10, 10, 10, 20 days (was 13, 13, 13, 10, 7, 15)
  • Exp rates: 650 exp/day or 1850 exp/day (multiples of simple numbers)
  • FK rates: 1 fk/day or 5 fk/day (integers)
  • FD rates: 0, 0.4, 0.5, 1 fd/day (simple fractions or integers)
  • All end stats still have integer stars using real calculation
  • Average 4870 exp/star only used for progression calculations

@Amund211
Copy link
Copy Markdown
Owner

@copilot the current index tests have good coverage and are in a good state, but fail because the code is not implemented yet. That is okay.

I want you to add the discriminant expectation to all the current test cases. Start by setting it to "positive" on all cases, and fix the tests that are failing because of this by setting it to the observed value. When all tests have and pass this check, they will fail because index calculation is not implemented yet. This is fine stop there

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot the current index tests have good coverage and are in a good state, but fail because the code is not implemented yet. That is okay.

I want you to add the discriminant expectation to all the ...

Done in 19cb37c. Added discriminant expectations to all 13 test cases:

  • 6 cases with discriminant "zero"
  • 1 case with discriminant "negative"
  • 6 cases with discriminant "positive"

All tests now pass the discriminant checks and fail only due to the "Not implemented" feature, as expected.

@Amund211
Copy link
Copy Markdown
Owner

@copilot
Move the discriminant property of the test cases into the expected object. Make a new object under expected with the key cubic. Make the value an object with the key discriminant.

expected: {
index: ...,
...,
cubic: {
discriminant: ...,
}
}

Make assertions on the coefficients of the cubic to check that we cover interesting cases.
Add properties a, b, c, d into this new cubic object and give it the same type as discriminant.
Do the same process where you set all of them (a, b, c, d) to expect "positive" for all the test cases and then update the test cases to reflect the actual value. Ensure all the test cases pass the "cubic" validation that we just added and that they go on to fail with "not implemented" as expected.

The equation expectations will be incorrect when the final deaths are 0. Don't add anything to the cubic object for the name: "increasing fkdr, zero final deaths, stable stars",
test case for this reason

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 15, 2026

@copilot
Move the discriminant property of the test cases into the expected object. Make a new object under expected with the key cubic. Make the value an object with the key discriminant.

...

Done in 20db95e. Restructured cubic expectations:

  • Moved discriminant from trackingStats to expected.cubic.discriminant
  • Added coefficient checks a, b, c, d to expected.cubic
  • Excluded "increasing fkdr, zero final deaths, stable stars" from cubic checks (no cubic object)
  • Set all to "positive" initially, then updated based on observed values
  • All 12 tests with cubic objects now pass validation (discriminant + 4 coefficients)
  • All tests fail only with "Not implemented" as expected

Copilot AI and others added 2 commits January 15, 2026 22:59
- Added new top-level test "computeStatProgression - index stat"
- Created single subtest "success cases" with 6 test scenarios
- Each test defines start/end stats (experience, finalKills, finalDeaths), duration, and expected values
- Tests cover various scenarios:
  * Basic steady progress on all stats
  * Zero final deaths at start (trending down)
  * Zero final deaths overall (always)
  * No experience progress
  * Improving from low index
  * Large values with steady ratios
- All test cases use simple integers and include thorough mathematical explanations
- Tests correctly fail with "Not implemented" error as expected
- All existing tests continue to pass

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
Copilot AI and others added 16 commits January 15, 2026 22:59
- Move durationDays, start, and end into nested trackingStats object
- Remove "Stats" suffix from start/end (now scoped within trackingStats)
- Move endValue and nextMilestoneValue back into main assertion
- Set trendingUpward dynamically to milestone >= endValue
- Keep only daysUntilMilestone and progressPerDay as float comparisons

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
- Updated all test cases to have integer star values at end stats
- Use real star calculation (bedwarsLevelFromExp) for actual end index
- Keep average exp/star (4870) only for progression calculations
- Adjusted durations and stats to maintain similar progression rates
- Test 1: 500->7000 exp (1->4 stars), 13 days
- Test 2: 500->7000 exp, zero deaths at start
- Test 3: 500->7000 exp, zero deaths overall
- Test 4: 500->500 exp (no exp progress)
- Test 5: 500->7000 exp, improving from low index
- Test 6: 487000->524000 exp (100->110 stars), 15 days

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
- Changed awkward durations (13, 7, 15 days) to simpler integers (10, 10, 10, 10, 10, 20 days)
- Updated stats to maintain integer or simple fraction rates:
  * 650 exp/day (most tests), 1850 exp/day (large test)
  * 1 fk/day, 5 fk/day (integers)
  * 0.5 fd/day, 0.4 fd/day (simple fractions)
- All end stats still have integer stars (1->4 stars, 100->110 stars)
- Use real star calculation for actual end index
- Use average 4870 exp/star only for progression calculations
- Recalculated expected milestone values and progression rates

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
One case still needs recompute.
- Added discriminant field to all 13 test cases
- Set discriminant to "zero" for 6 cases: no progress, no finals, no stars, increasing star with stable fkdr, increasing fkdr with zero final deaths, and increasing plateauing fkdr
- Set discriminant to "negative" for 1 case: index increasing past next milestone
- Set discriminant to "positive" for remaining 6 cases
- Removed TODO comment about discriminant expectations
- All tests now pass discriminant checks and fail only due to "Not implemented" feature

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
- Moved discriminant from trackingStats to expected.cubic.discriminant
- Added a, b, c, d coefficient checks to expected.cubic
- All coefficients have type "positive" | "zero" | "negative"
- Updated test assertions to check all cubic properties
- Excluded "increasing fkdr, zero final deaths, stable stars" from cubic checks per instruction
- Set all coefficients initially to "positive" then updated based on actual values:
  * 6 tests with a="zero" (no exp progress)
  * 4 tests with b="zero" or "negative"
  * 3 tests with c="zero" or "negative"
  * Various d values (positive, zero, negative)
  * discriminant values: 6 zero, 1 negative, 6 positive
- All tests pass cubic validation and fail only with "Not implemented"

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
@Amund211 Amund211 force-pushed the copilot/add-index-stat-progress-tests branch from 30b6eea to ccc5165 Compare January 15, 2026 21:59
@Amund211
Copy link
Copy Markdown
Owner

Moved to #135

@Amund211 Amund211 closed this Jan 15, 2026
@Amund211 Amund211 deleted the copilot/add-index-stat-progress-tests branch January 15, 2026 22:04
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.

2 participants