This homework is about finding a path in a labyrinth modelled as ann×n-grid of white and blackcells. Suppose a robot starts in the upper lefthand corner and wants to move to the lower righthandcorner. It can move horizontally and vertically (but not diagonally), and it can only move via whitecells. In Prolog, we represent the grid as a list of lists of the atomsw(forwhite) andb(forblack).We store the grid given to us using the predicate grid/1.
We represent cells as terms of the formX/Yand we represent the current state as the cell at whichthe robot currently is located. First implement a predicate calledwhite/1that you can use to checkwhether a given cellX/Yis white. Then implement a predicatemove/2which generates all legalfollow-up states for a given state, when used with enforced backtracking.
Comments
Leave a comment