Closed sun1991 closed 4 years ago
Yes, this is actually mentioned on page 50 as a justification for why we use bfs() to solve the problem "This solution uses bfs() (because using dfs() would require marking referentially different states with the same value as equal, and astar() would require a heuristic)."
It is also alluded to in exercise 3 at the end of Chapter 2; you'll see that implementing hash() is mentioned. It's convenient that it works for 3/3 with bfs(), but would require hash() to be robust for other algorithms/scenarios. You're right this should arguably be more explicit in a future edition. Thanks for bringing it up.
In Chapter2/generic_search.py, if an object is used in Set or Dict, shouldn't it implement its own
__hash__
?For example: generic_search.py
missionaries.py
I don't see
MCState
implement its__hash__
, which means by default, all objects will compare unequal except with themselves?