Skip to content

Repository files navigation

GRIND — Official Rules

The Game

Grind is a solo dice-placement game played on a 3×3 grid.

The player rolls a standard six-sided die nine times. After each roll, the die is placed on any empty cell of the grid. When all nine cells are filled, the grid is scored.

Your Task

Implement the scoring function. It takes a completed grid — nine die faces (1–6), given row by row — and returns the total score.

How the dice got there is not your concern for now. Placement strategy is out of scope; assume the grid arrives already filled.

Scoring

The grid contains six lines: three rows and three columns. The grid's total score is the sum of the six line scores, plus any bonus.

A face a die actually shows is called its natural face.

Wilds. A die showing a natural 1 is wild: for the purpose of pattern detection, it may be declared as any face. A declared face is never natural. Regardless of what it is declared as, a wild always contributes exactly 1 to a sum.

Wild exclusivity. Every die belongs to one row and one column. A wild may use its wildness in at most one of its two lines. In the other line, it is treated as an ordinary natural 1 — no declaration allowed.

The Sworn Center. The die on the center cell is never wild, even if it shows a 1. In both of its lines it is an ordinary natural 1.

The Curse. A line containing two or more natural 6s scores 0. This is absolute and overrides every other rule.

A line that is not cursed is scored as follows:

  1. Triple — all three dice show the same face (declarations allowed): the line scores 10 × the highest natural face in the line. If the line has no natural face, use 1.
  2. Straight — the three dice show consecutive values, in any order (e.g. 3-1-2 or 4-6-5; declarations allowed): the line scores 15.
  3. Sum — otherwise, the line scores the sum of its three faces (wilds contribute 1).

Within each line, the player declares any usable wilds optimally. Across the grid, the player chooses where each wild spends its wildness optimally: the grid scores the maximum total achievable over all legal combinations of these choices.

Corner Bonus. If all four corner cells show the same natural face, add 25 to the total.

Examples

This table shows some examples of a line and the associated score, and why.

line score why
4, 4, 4 40 Triple: 10 × 4
2, 4, 3 15 Straight: 2-3-4
2, 2, 5 9 Sum: 2 + 2 + 5
5, 3, 5 13 Sum: 5 + 3 + 5
3, 3, 1 30 Wild declared 3 — if its wildness is spent here
6, 6, 3 0 The Curse: two natural 6s

Line examples above assume the wild in question is usable in that line. Whether it is depends on the whole grid.

Grid Examples

Each grid below is given row by row.

A grid with no wilds

Nothing is wild, so each of the six lines scores on its own and the total is their sum.

The grid is:

4 4 4
2 4 3
2 2 5

Its rows score 40, 15 and 9, and its columns score 8, 10 and 15.

The total score is 97.

A wild serves one line only

The 1 in the top-left corner belongs to the top row and the left column. Declared 3 it makes the top row a triple worth 30; declared 2 it makes the left column a triple worth 20. It cannot do both, so it spends its wildness on the row, and the left column treats it as an ordinary natural 1.

The grid is:

1 3 3
2 4 5
2 6 4

Its rows score 30, 11 and 12, and its columns score 5, 13 and 15.

The total score is 86.

The sworn center is never wild

The 1 on the center cell shows a natural 1, but the center is sworn and cannot be declared. Were it wild, the middle row would be a triple of 5s worth 50; instead the row is summed.

The grid is:

2 3 4
5 1 5
6 2 3

Its rows score 15, 11 and 11, and its columns score 13, 15 and 15.

The total score is 80.

Matching corners earn the bonus

All four corners show a natural 2, so 25 is added to the sum of the six line scores.

The grid is:

2 5 2
3 4 6
2 5 2

Its rows score 9, 13 and 9, and its columns score 7, 14 and 10.

The total score is 87.

The Curse empties a line but not its dice

The top row holds two natural 6s and scores nothing. Those same 6s still count in the columns they belong to, neither of which is cursed.

The grid is:

6 6 2
3 4 5
2 3 6

Its rows score 0, 15 and 11, and its columns score 11, 13 and 13.

The total score is 63.

Two wilds are placed together, not one at a time

Neither wild in the top row is worth anything there on its own — the row becomes a triple of 5s only if both are declared 5. Considered one at a time, each wild would rather make its own column a triple of 2s worth 20, and that is the wrong answer: sending both to the row scores 60 across the three lines they touch, against 47 for sending both to the columns.

The grid is:

1 5 1
2 6 2
2 4 2

Its rows score 50, 10 and 8, and its columns score 5, 15 and 5.

The total score is 93.

About

A made up dice game built with Varar

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages