GithubHelp home page GithubHelp logo

mypan / sudoku-genetic-algorithm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ctjacobs/sudoku-genetic-algorithm

0.0 0.0 0.0 19 KB

Solves a Sudoku puzzle using a genetic algorithm.

Python 100.00%

sudoku-genetic-algorithm's Introduction

Overview

This project is capable of solving a Sudoku puzzle using a genetic algorithm. Puzzle configurations are read in from a plain text file containing a string of 9 x 9 digits separated by spaces, with an example provided in the file puzzle_mild.txt. Zero is used to represent an unknown digit, whereas numbers in [1, 9] are assumed to be known/given.

Run the code by executing python sudoku.py at the command line. Example output looks like this:

~/sudoku-genetic-algorithm $ python sudoku.py 
Seeding complete.
Generation 0
Best fitness: 0.286694
Generation 1
Best fitness: 0.303155
Generation 2
Best fitness: 0.303155
Generation 3
Best fitness: 0.303155
Generation 4
Best fitness: 0.303155
Generation 5
Best fitness: 0.390947
Generation 6
Best fitness: 0.473251
Generation 7
Best fitness: 0.473251
Generation 8
Best fitness: 0.473251
Generation 9
Best fitness: 0.473251
Generation 10
Best fitness: 0.473251
Generation 11
Best fitness: 0.489712
Generation 12
Best fitness: 0.489712
Generation 13
Best fitness: 0.489712
Generation 14
Best fitness: 0.489712
Generation 15
Best fitness: 0.489712
Generation 16
Best fitness: 0.536351
Generation 17
Best fitness: 0.536351
Generation 18
Best fitness: 0.536351
Generation 19
Best fitness: 0.536351
Generation 20
Best fitness: 0.536351
Generation 21
Best fitness: 0.536351
Generation 22
Best fitness: 0.536351
Generation 23
Best fitness: 0.547325
Generation 24
Best fitness: 0.547325
Generation 25
Best fitness: 0.547325
Generation 26
Best fitness: 0.547325
Generation 27
Best fitness: 0.604938
Generation 28
Best fitness: 0.604938
Generation 29
Best fitness: 0.604938
Generation 30
Best fitness: 0.604938
Generation 31
Best fitness: 0.604938
Generation 32
Best fitness: 0.851852
Generation 33
Best fitness: 0.851852
Generation 34
Best fitness: 0.851852
Generation 35
Best fitness: 0.851852
Generation 36
Best fitness: 0.851852
Generation 37
Solution found at generation 37!
[[ 8.  3.  9.  2.  7.  4.  6.  5.  1.]
 [ 5.  2.  4.  1.  3.  6.  7.  8.  9.]
 [ 7.  6.  1.  5.  8.  9.  4.  2.  3.]
 [ 1.  9.  7.  8.  5.  3.  2.  6.  4.]
 [ 6.  8.  3.  4.  9.  2.  5.  1.  7.]
 [ 2.  4.  5.  6.  1.  7.  9.  3.  8.]
 [ 3.  5.  2.  7.  4.  1.  8.  9.  6.]
 [ 9.  7.  8.  3.  6.  5.  1.  4.  2.]
 [ 4.  1.  6.  9.  2.  8.  3.  7.  5.]]

sudoku-genetic-algorithm's People

Contributors

ctjacobs avatar fabricecoulon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.