I implemented it using iterative deepening depth-first search algorithm. My state is represented by a 3-element vector where A represents the side of the boat (0/1