aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
8.05k stars 3.81k forks source link

NQueensProblem doesn't work with search methods #711

Closed PeterDrake closed 6 years ago

PeterDrake commented 6 years ago

If I import search and then

puzzle = search.NQueensProblem(8)
print(search.breadth_first_search(puzzle))

I get:

TypeError: unhashable type: 'list'

In order to work with the various search algorithms, the states have to be tuples, not mutable lists.

BraveNewPumpkin commented 6 years ago

same issue. Please make NQueensProblem or NQueensCSP work with astar_search, forward_checking, etc.

norvig commented 6 years ago

The fix should be to make the NQueensProblem produce tuples, not to make search coerce states to tuples.

ad71 commented 6 years ago

I completely forgot about this issue until now. I assign myself the task of fixing this problem and rewriting the notebook section of NQueensProblem.