Project briefing illustration for five-dice scoring: a flat tactical intelligence sheet in the style of Star Fox Assault.
ACADEMIC PROJECT / Computer Science Course

Java Farkle Dice Scoring

I traced a scoring defect to a counter that lost its meaning, separated scoring from random play, and checked all 7,776 ordered five-dice outcomes under an explicitly provisional doubling rule.

Javadicepure functionsexhaustive testingrestoration

How I traced the multiplier defect

When I revisited this five-dice game, I traced a scoring defect to a helper that counts scoring dice, decrements that count while processing them, and then checks the resulting zero to decide whether to double the score. Because the helper consumes its counter, every scoring roll reaches the multiplier. I wanted to repair that loss of meaning and make the scoring easy to verify.

In October 2026, I revisited the July 24, 2023 project, separated deterministic scoring from random interaction, and tested every ordered five-dice outcome. I kept the replacement doubling condition labeled as a documented interpretation because the assignment rubric was not recovered.

How I separated known rules from an interpretation

I first wrote down what the source establishes: five dice, 100 points for each one, 50 points for each five, and a goal of 1,000 banked points. The player can roll again to increase an unbanked round score or stop and add it to the total. A roll with no scoring dice ends the round and discards its accumulated points.

For the repaired edition, I double a roll only when all five dice score. I treat that choice as provisional and would check it against the original prompt if recovered. I describe this as a course-style roll-and-bank variant: its name does not establish triples, straights, six dice, selective die retention, or every rule used in other Farkle games.

THE CHALLENGE

The challenge: keeping the scoring counter meaningful

PROJECT STEPS

How I preserve the scoring decision

Project briefing illustration for five-dice scoring: a flat tactical intelligence sheet in the style of Star Fox Assault.
STEP 01 OF 05
Validate five dice

In my repaired Farkle scoring function, I require exactly five whole-number die values from one through six before calculating points. I separate scoring from console input and random rolls so I can repeat any given roll directly and reject invalid lengths or values at one clear boundary. My exhaustive scoring checks assess this function, while the random generator’s quality remains outside those checks.

Select a step to follow the project.
Read all step descriptions
  1. Validate five dice

    In my repaired Farkle scoring function, I require exactly five whole-number die values from one through six before calculating points. I separate scoring from console input and random rolls so I can repeat any given roll directly and reject invalid lengths or values at one clear boundary. My exhaustive scoring checks assess this function, while the random generator’s quality remains outside those checks.

  2. Accumulate base points

    I calculate the base score by adding 100 points for each one and 50 for each five, following the rules supported by the source. Keeping this sum separate lets me inspect rolls in which only some dice score. I do not add rules for triples, straights, keeping selected dice, or other versions of Farkle, because the project’s name alone does not establish them.

  3. Retain the count

    I keep the number of scoring dice separate from the point total and leave that count unchanged while processing the roll. The earlier helper reduced the count as it worked, causing every scoring roll to reach the doubling step. Giving these two values consistent meanings lets me decide whether to double using the actual number of scoring dice.

  4. Apply the stated rule

    For my 2026 repair, I double the roll’s score only when all five dice contribute points. I label this rule as a provisional interpretation because the original grading rubric was not recovered. I check an example with one scoring die to distinguish the repair from the defect, since an example where all five score would allow both versions to appear correct.

  5. Check every roll

    I check all 7,776 ordered five-dice outcomes against an expected score calculated independently by counting scoring dice. Checking different arrangements of the same values helps me spot behavior that accidentally depends on a die’s position. These checks cover the scoring function under the provisional doubling rule; they do not cover every random sequence of rounds or recover the missing rubric.

Restored scoring model: the all-five doubling rule remains a documented 2026 interpretation.

I gave calculatePoints a narrow boundary: exactly five integer die values, each from 1 through 6. It rejects any other length or value and returns a score without reading console input or generating randomness.

That separation lets me reproduce any roll directly instead of waiting for chance, and it lets parser tests stay independent of the scoring formula. I retained SecureRandom in the console, but I do not treat randomness as part of the scoring proof.

To fix the consumed-counter problem, I kept two variables with stable meanings: the base score and the number of scoring dice. This excerpt shows the core response:

Illustrative java example
int points = 0;
int scoring = 0;
for (int die : dice) {
    if (die == 1) {
        points += 100;
        scoring++;
    } else if (die == 5) {
        points += 50;
        scoring++;
    }
}
return scoring == 5 ? points * 2 : points;

I validate arguments before that excerpt. The critical change is that scoring still means the number of scoring dice when I reach the multiplier decision; I never reuse it as a countdown.

How I chose examples that expose the bug

I needed tests that distinguish the defect from the repair. An all-scoring roll alone would be weak because both the defective behavior and my provisional interpretation double it.

I therefore check [1,2,3,4,6] for 100: only one die scores, so no multiplier applies. For [1,1,5,5,5], I expect a base of 350 doubled to 700 because all five dice score. A roll such as [2,3,4,6,2] must score zero and trigger the round-loss path.

I also include a single-five case and mixed scoring cases, and check invalid inputs separately so malformed values cannot disappear inside an otherwise correct arithmetic test.

How I checked every ordered roll

I can enumerate the whole scoring input space because each of five ordered positions has six possible values: five nested loops visit 6⁵, or 7,776, outcomes. For each roll, I use an independent count-based expectation to count ones and fives, calculate base points, and decide whether all five positions score.

I compare calculatePoints with that expectation for every outcome. Ordered enumeration includes positional permutations with the same score, and that repetition helps catch code that accidentally treats one die position differently.

The October 2026 record reports six targeted checks and all 7,776 ordered outcomes passing. I limit that exhaustive claim to the five-die scoring function and its documented interpretation. It does not establish random-generator quality or exercise every possible multi-round conversation.

How I kept temporary points separate from the bank

I keep each round's temporary balance separate from the bank. A scoring roll increases the temporary balance; y rolls all five dice again; n transfers that balance to the banked total. A zero-scoring roll abandons the temporary balance while leaving the bank unchanged.

I use the banked total for the winning condition. Reaching 1,000 tentative points while still choosing to roll does not end the game under this flow. Treating the bank as committed state makes the risk explicit and keeps a bust from accidentally preserving unbanked points.

In the restored interaction, I normalize y, n, and q, repeat the prompt for unsupported choices, and terminate at end-of-file. An EOF smoke test confirms that the console can start and exit. I source-reviewed the full random multi-round path; the scoring suite did not exhaustively drive it.

What I learned while keeping the uncertainty visible

I ended with a testable implementation of an explicitly stated rule, not a recovered rubric inferred from passing tests. I keep the new interpretation, validation, and test results attributed to the October 2026 restoration.

My main lesson was concrete: a counter should keep one meaning, a pure function makes exhaustive testing practical, and a successful test run proves only the rule encoded by its expectations.

PROJECT WALKTHROUGH

Recovered source repaired in October 2026. Six targeted checks and 7,776 ordered dice outcomes recorded; the all-five-scoring multiplier is an explicit provisional reconstruction assumption.

Validation & limitations

  • Recovered source repaired in October 2026. Six targeted checks and 7,776 ordered dice outcomes recorded; the all-five-scoring multiplier is an explicit provisional reconstruction assumption.

Project records

  • Project artifacts and historical records, July 24, 2023 submission evidence
  • Restoration and public documentation, October 1, 2026
END OF PROJECT FILE RETURN TO ARCHIVE