Skip to content

Latest commit

 

History

History
89 lines (68 loc) · 2.48 KB

Tazuku.md

File metadata and controls

89 lines (68 loc) · 2.48 KB

Tazuku Solver

Game

Tazuku, also known as binary sudoku is a binary-determination logic puzzle played on a square grid. The aim of the game is to fill empty cells with values of either 0 or 1 based on information given from neighbouring cells. A complete game should have all the cells filled in a fashion where all the rules are satisfied.

Rules

  1. Each row and column has to be made up of the same amount of 0 and 1 cells
  2. No 2 rows or columns can be the same
  3. No 3 consecutive tiles in a row or column can be of the same colour

Algorithm

The intuition of the algorithm is to iteratively loop over the each row and column and matching patterns of already set cells. Each of the game rule can be converted into a pattern that could be looked for.

Patterns

Pattern 1

  • Requirement
    • Half of the cells of a row or column are of the same type (0 or 1)
  • Action
    • Set remaining empty cells of the selected row or column to the other type

Pattern 2

  • Requirements
    • Row or column A is completely filled and valid
    • Row or column B has 2 remaining empty cells
    • A and B match perfectly except the remaining 2 cells
  • Action
    • Fill the remaining cells of B opposite to what is in A

Pattern 3

  • Requirements
    • Presence of these pattern in the row or column
      • Patterns (in regex; empty cells are represented with -)
        • Type 0
          • -00, 00-, 0-0
        • Type 1
          • -11, 11-, 1-1
  • Action
    • Fill the empty cell from the matched pattern with the opposite cell type
      • Fill cell with 1 for Type 0 patterns
      • Fill cell with 0 for Type 1 patterns

(Pattern indices correspond to each game rule)

Algorithm Structure

Highly abstracted algorithm pseudo-code

bool hasBoardUpdated = true;
while (hasBoardUpdated) {
	hasBoardUpdated = false;
	if (sectionHasPattern1(board)) {
        enforceRule1(board);
		hasBoardUpdated = true;
    }
    if (sectionHasPattern2(board)) {
        enforceRule2(board);
		hasBoardUpdated = true;
    }
    if (sectionHasPattern3(board)) {
        enforceRule3(board);
		hasBoardUpdated = true;
    }
}

Config Setup

The following is an example config file.

--1---
------
0--01-
---0--
----1-
00-1--
  • - represent blank tiles
  • Numbers correspond to originally numbered tiles
    • 0 and 1 are interchangable, but must be consistent throughout