A Selective Macro-learning Algorithm and its Application to the NxN Sliding-Tile Puzzle