From Sudopedia, the free Sudoku reference guide
Rule File format
From Sudopedia
The rule file format (*.rf) is a file format that allows it to describe puzzle rules and puzzles of a great variety. It is text based and can be read by humans as well as by computers. Every information for a property of a puzzle is set by a single line. These lines start in column 1. Comments start with two slashes. Spaces in a line are ignored. The rule file for vanilla sudoku for example is:
values = 123456789 // the values that are used, could be letters as well columns = 9 // the number of columns in a rectangular grid rows = 9 // the number of rows in a rectangular grid column_groups // the values in a column must be different row_groups // the values in a row must be different box_groups(3,3) // the values in a 3x3 box must be different
Given values in cells are given with:
set_cell(12,1) // R2C3 is set to 1, we count the cells row by row from the upper left to the bottom right
For easier reading and parsing the condition values is the first condition, it follow the grid definitions ( columns, rows, hexangular_grid) and then the rest.
Values
values
Defines the values that the cells of a puzzle can have. In Sudoku it is
values = 123456789
It is possible to have letters. Lower case and upper case letters are considered to be different.
Example:
values = xyzabcABC
In some puzzle variants there can be in rows, columns ... some numbers repeated. In this case we repeate the values also in the values condition.
Example: We want to have in a 6x6 grid the value 1 one time, the value 2 two times and the value 3 three times in every row and column. Then we use:
values=122333
In some puzzles, for example in Killer Sudoku, the values are used to make additions, multiplications, greater-equal-conditions ... In the cases the numbers are given in the order of the first occurance in the values condition.
Example:
values=adbbbccb
In this example for calculations we use a = 1, d = 2, b = 3, c = 4. So a would be less d, d less c, a + d = b ...
values=123456789
works fine.
empty_value
symvalue
Rectangular grids
columns
Gives the number of columns if a grid is rectangular.
Example: In standard Sudoku we would have
columns=9
rows
Gives the number of rows if a grid is rectangular.
Example: In standard Sudoku we would have
rows=9
column_groups
Columns of a rectangular grid can only have the values as often as in the values condition.
column_groups
This is the condition of standard sudoku that all values in a column must be different.
row_groups
Rows of a rectangular grid can only have the values as often as in the values condition.
row_groups
This is the condition of standard sudoku that all values in a row must be different.
box_groups
Boxes with the given size of a rectangular grid can only have the values as often as in the values condition. The boxes are started in the upper left corner as often as they can placed.
Example: The boxes have a width of 3 cells and a height of 2 cells:
box_groups(3,2)
The condition of standard sudoku that all values in a 3x3 box must be different is
box_groups(3,3)
Hexagonal grids
hexagonal_grid
This rule defines a hexagonal grid and its size. The first number is the number of cells in the base line, the second number is the number of cells in the middle line. The cells are counted row by row from the upper left to the bottom right
Example:
The standard grid for Hanidoku is:
hexagonal_grid(5,9)
hexagon_lines
Lines in all 3 possible directions of a hexagonal grid can only have the values as often as in the values condition.
hexagon_lines
in Sudoku Hexagon and Hanidoku this is the rule that the lines in all 3 directions must be different.
Example Sudoku Hexagon:
Fill the numbers 1 through 6 in the grid. In all three directions no number can be repeated.
Rule File:
// example sudoku hexagon values=123456 hexagonal_grid(4,6) hexagon_lines set_cell(2,5) set_cell(6,4) set_cell(9,5) set_cell(14,1) set_cell(16,3) set_cell(17,5) set_cell(22,6)
For a Hanidoku example see the renban condition.
Multiple grids
conjoined_columns
conjoined_rows
conjoined_box
four_doku
four_doku_columns
four_doku_rows
four_doku_box
twin_doku
twin_doku_columns
twin_doku_rows
twin_doku_box
twodoku_columns
twodoku_rows
twodoku_box
three_grid
three_grid_box
three_grid_rows
three_grid_columns
two_grid
two_grid_box
two_grid_columns
two_grid_rows
restrict_grid
Grid properties
no_modulo
renban
renban
This condition is used for example for puzzles like Renban or Hanidoku.
All groups given with row_groups, column_groups, hexagon_lines, diagonal, extra_region must contain consecutive values, i. e., if such a group has five cells there can be 2, 3, 4, 5, 6 or 3, 5, 4, 2, 6 but not 3, 4, 1, 9, 2, 8 in the cells.
To learn how the used number of a value is calculated see the values condition.
Example:
Little Hanidoku
Put the numbers 1 through 6 into the hexagonal cells so that every line (of any length) contains every digit not more than once. The lines must contain consecutive numbers, i. e., if a line has four cells there can be 2, 3, 4, 5 or 3, 5, 4, 2 but not 3, 4, 1, 6 in the cells.
The rule file is the following:
// example Little Hanidoku values=123456 hexagonal_grid(4,6) hexagonal_lines renban set_cell(7,1) set_cell(9,5) set_cell(18,6) set_cell(23,3)
ripple_cages
different_adjacent
japanese_crossword
non_consecutive
ripple_effect_distance
repetition
Allows in sum and product cages the repetition of values.
Extra regions
diagonal
Defines a diagonal for rectangular grids which can only have the values as often as in the values condition. Both ends of the diagonals are given. It works also for shorter diagonals.
Example:
The rule file of Sudoku-X is the following:
values = 123456789 columns = 9 rows = 9 column_groups row_groups box_groups(3,3) diagonal(1,81) diagonal(9,73)
The rule file of Argyle Sudoku is the following:
values = 123456789 columns = 9 rows = 9 column_groups row_groups box_groups(3,3) diagonal(2,72) diagonal(5,37) diagonal(5,45) diagonal(8,64) diagonal(10,80) diagonal(18,74) diagonal(37,77) diagonal(45,77)
extra_region
Defines a additional set of values which can only have the values as often as in the values condition.
Examples:
The rule file of Asterisk is the following:
values = 123456789 columns = 9 rows = 9 column_groups row_groups box_groups(3,3) extra_region(14,21,25,38,41,44,57,61,68)
The rule file of Hypersudoku (Windoku) is the following:
values = 123456789 columns = 9 rows = 9 column_groups row_groups box_groups(3,3) extra_region(11,12,13,20,21,22,29,30,31) extra_region(15,16,17,24,25,26,33,34,35) extra_region(47,48,49,56,57,58,65,66,67) extra_region(51,52,53,60,61,62,69,70,71)
If we were to have a 007 Hypersudoku where in every row, every column, every box and every extra region the digits 1 through 7 must occur once and the digit 0 must occur twice we would have the following rule file:
values = 123456700 columns = 9 rows = 9 column_groups row_groups box_groups(3,3) extra_region(11,12,13,20,21,22,29,30,31) extra_region(15,16,17,24,25,26,33,34,35) extra_region(47,48,49,56,57,58,65,66,67) extra_region(51,52,53,60,61,62,69,70,71)
jigsaw
Has the same function as extra region but is used if the extra regions are a substitute of the boxes. Additional there is a difference between extra region and jigsaw with respect to the renban condition. (see there).
Constraint of single cells
set_cell
Gives the value of a cell. We count the cells row by row from the upper left to the bottom right. The first number is the number of the cell. The second the name of the value (could also be a letter if letters in the values condition).
Example: Cell R2C3 in a standard sudoku should be 3:
set_cell(12,3)
set_values
Gives the possible values of a cell. We count the cells row by row from the upper left to the bottom right. The first number is the number of the cell. The other values are the names of the possible values (could also be letters if letters in the values condition).
Examples:
Cell R2C3 in a Sukaku can have the values 2, 3, 5 or 7:
set_values(12,2,3,5,7)
Cell R2C3 in a Sudoku 147 can have the values 1, 2 or 3:
set_values(12,1,2,3)
del_value
Gives the impossible values of a cell. We count the cells row by row from the upper left to the bottom right. The first number is the number of the cell. The other values are the names of impossible values (could also be letters if letters in the values condition).
Example: Cell R2C3 in a Sukaku can not have the values 1, 4, 6, 8, 9:
del_values(12,1,4,6,8,9)
even
Says that a cell or a set of cells must be even. The values are calculated as defined in the values condition.
Example: The cells R2C2, R5C5 and R7C3 should be even.
even(11,41,57)
odd
Says that a cell or a set of cells must be odd. The values are calculated as defined in the values condition.
Example: The cells R2C2, R5C5 and R7C3 should be odd.
odd(11,41,57)
Constraints of cell pairs
diff
nodiff
nodiff_adjacent
mindiff
ratio
no_kropki
equal
neq
pencil
modulo3
kropki_sum
kropki_sum2
kropki_factor
kropki_diff
Constraints of cell triples
circlediff
circlepower
Constraints of cell quadruples
wheel
Constraints of cell sets
sum
This standard constraint of Killer defines the sum of some (at least two) cells. The numbers of the values are calculated as in the description of the 'values' condition defined. If the condition reptition is not used then values can't be repeated in the summand cells.
Example:
The sum of cell R1C2, R2C2 and R2C3 in a standard sudoku grid is 8:
sum(8,2,11,12)
kimo_sum
modulo
no_kimo_sum
product
This constraint defines the product of some (at least two) cells. The numbers of the values are calculated as in the description of the 'values' condition defined. If the condition reptition is not used then values can't be repeated in the factor cells.
Example:
The product of cell R1C2, R2C2 and R2C3 in a standard sudoku grid is 16:
product(16,2,11,12)



