like rooks in chess, but cannot stop until they hit an obstacle (a wall or another robot) Goal: Get the “active” robot to the “target” square in the fewest moves possible Use the non-active robots as helpful obstacles
one for each square) with 5 bits used for each One bit for each direction (N, S, E, W) to represent presence of a wall in that direction One bit to represent presence of a robot Array of 4 integers to represent position of each robot (so we don’t have to scan for them)
4 robots and 4 directions... maximum branching factor of 16 Searching just 10 moves deep requires evaluating 2,294,544,866 positions! It would take years to compute a 22 move solution
current position has already been searched to an equal or greater depth, prune the search This helps significantly, as duplicate positions are very common in the search tree
represent a position with a single 32-bit integer! Implement a hash table mapping 32-bit integer (position) to another integer (depth searched) 22-move puzzle becomes solvable with about 3 minutes of processing time
reach the target square from all other squares (assuming the robot could stop moving at anytime, like a rook, e.g. if other robots were in ideal positions) While searching, prune search whenever active robot cannot reach the target square in the number of moves remaining for the current search depth