In my prior post, I laid out the problem of the eight-puzzle.

In this post, I want to examine finding a solution from a starting point leveraging search techniques. As a reminder, the solution space is a graph of puzzle states and moves to subsequent states, for example:

Each state is a pair of an ID (or key) and its value an array of what tile is in which puzzle spot. The graph contains 362,880 nodes and 967,680 edges. Brute force search is capable but really not an optimal technique. More informed methods are a more efficient choice but require a bit more work.

Breadth-First

Breadth-First Search (BFS) starts by examining the first node and expands one layer at a time, for example, all nodes “one hop” from the first node; once those are exhausted it proceeds to all nodes “two hops” from the first node and so forth.

#computer-science #coding #javascript #artificial-intelligence

Solving 8 Puzzle: Exploring Search Options
1.10 GEEK