Constraint Processing

Aus ProgrammingWiki
Archivierte Version vom 2013-06-13T11:30:52+00:00. Aktuelle Version

CP solver for the Sudoku game

Introduction

Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called "boxes", "blocks", "regions", or "sub-squares") contains all of the digits from 1 to 9. The puzzle setter provides a partially completed grid, which typically has a unique solution.

Sudoku.png --> Sudoku2.png

Modeling Sudoku as Constraint Satisfaction Problem

Variables: X_{11},...,X_{99}

Domains: {1,..,9}

Constraints:

  • Row Constraints X_{11} \neq X_{12},..,X_{11} \neq X_{19} etc.
  • Column Constraints X_{11} \neq X_{21},..,X{11} \neq X_{91} etc.
  • Block Constraints X_{11} \neq X_{12},..,X_{11} \neq X_{33} etc.