ctjacobs / sudoku-genetic-algorithm Goto Github PK
View Code? Open in Web Editor NEWSolves a Sudoku puzzle using a genetic algorithm.
Solves a Sudoku puzzle using a genetic algorithm.
File "C:\Users\M\Downloads\sudoku-genetic-algorithm-master\sudoku.py", line 499, in
solution = s.solve()
File "C:\Users\M\Downloads\sudoku-genetic-algorithm-master\sudoku.py", line 430, in solve
child1, child2 = cc.crossover(parent1, parent2, crossover_rate=1.0)
File "C:\Users\M\Downloads\sudoku-genetic-algorithm-master\sudoku.py", line 294, in crossover
child1.values[i], child2.values[i] = self.crossover_rows(child1.values[i], child2.values[i])
File "C:\Users\M\Downloads\sudoku-genetic-algorithm-master\sudoku.py", line 310, in crossover_rows
remaining.remove(row1[index])
AttributeError: 'range' object has no attribute 'remove'
The following error occur when running the code with python 2 and 3.
Traceback (most recent call last):
File "/Desktop/sudoku.py", line 487, in
solution = s.solve()
File "/Desktop/sudoku.py", line 377, in solve
self.population.seed(Nc, self.given)
File "/Desktop/sudoku.py", line 64, in seed
self.update_fitness()
File "/Desktop/sudoku.py", line 73, in update_fitness
candidate.update_fitness()
File "/Desktop/sudoku.py", line 108, in update_fitness
column_count[self.values[i][j]-1] += 1 # ...Update list with occurrence of a particular number.
IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
using python3 and the same puzzle_mild.txt file. Any suggestions?
Seeding complete.
Generation 0
Best fitness: 0.303155
sort() takes no positional arguments
Stack trace:
File "C:\Users\R\source\repos\SGA\SGA\SGA.py", line 78, in sort
self.candidates.sort(self.sort_fitness)
File "C:\Users\R\source\repos\SGA\SGA\SGA.py", line 414, in solve
self.population.sort()
File "C:\Users\R\source\repos\SGA\SGA\SGA.py", line 499, in (Current frame)
solution = s.solve()
do not use this, you will pull your hair out trying to get one single line of code to cooperate, the line "self.candidates.sort(self.sort_fitness)"
DOES NOT WORK and you can not make it work first it throws the error "sort() takes no positional arguments" should be an easy fix just add key= before self.sort_fitness but nope gives you the error sort_fitness() missing 1 required positional argument: 'y'
so you add () after the sort_fitness function it gives you sort_fitness() missing 2 required positional arguments: 'x' and 'y' so then you add x and y then it tells you they are both undefined so then you set x and y equal to something in the method and it does not matter what you set x and y equal too it always returns the error object has no attribute 'fitness'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.