GeneticSharp v2.2.0 - Sudoku sample

The GeneticSharp v2.2.0 is out.

The additions of this version are the new whole sample and extensions showing how to use GeneticSharp to solve a Sudoku.

The GeneticSharp.Extensions project receive those new features:



Compound chromosome to artificially increase genetics diversity by evolving a list of chromosomes instead of just one. Sub-genes are inlined into a single compound list of genes.


Fitness class that can evaluate a compound chromosome by summing over the evaluation of its sub-chromosomes.



Represents each type of chromosome for solving a sudoku is simply required to output a list of candidate sudokus.


A class that represents a Sudoku, fully or partially completed. Holds a list of 81 int for cells, with 0 for empty cells. Can parse strings and files from most common formats and displays the sudoku in an easy to read format.


This simple chromosome simply represents each cell by a gene with a value between 1 and 9, accounting for the target mask if given.


Evaluates a sudoku chromosome for completion by counting duplicates in rows, columns, boxes, and differences from the target mask.


This more elaborated chromosome manipulates rows instead of cells, and each of its 9 gene holds an integer for the index of the row’s permutation amongst all that respect the target mask. Permutations are computed once when a new Sudoku is encountered, and stored in a static dictionary for further reference.


This chromosome aims at increasing genetic diversity of SudokuPermutationsChromosome, which exhibits only 9 permutation genes. Here, instead, an arbitrary number of Sudokus are generated where for each row, a random gene is picked amongst an arbitrary number of corresponding permutation genes.


GTK# sample gtk-sudoku-sample

Thanks to

I would like to thanks to Jean-Sylvain Boige (@jsboige) for contributing with those great new samples and extensions and for use GeneticSharp in his Artificial Intelligence course in French engineering schools (course).

Take a look on the pull-request for fore details about those new features: New Sudoku extension and GTK# sample #43.

Let’s evolve!

Written on November 3, 2018