Move the mouse around to move the Cat/Player. Press Space to change the sample Levels. Basically, this examples works like if you had a heat map when playing Hot & Cold. The map (or hierarchy of grid cells starting at the Player), is stored in a list called "Grid cell - hierarchical layer" and shows how many steps each grid cell is from the player. That map can be used by enemies to find their way to the Player. They just need to keep checking their neighboring cells, and move to one which is closer to the Player. There is a separate sprite (Illustrate Map) which use the Map and paints the stage: Red is close to the player, Green is far away, and Gray is blocked by the Level or Edge. This would, of course, not be used in a game or such. Look inside at the "Build hierarchical graph" custom block in the Map sprite. All code by me (@kriblo). The algorithm used to build the hierarchical graph is quite well described in this paper by Zhou et al, "A fewest-turn-and-shortest path algorithm based on breadth-first search" (Geo-spatial Information Science, 2014) https://www.tandfonline.com/doi/full/10.1080/10095020.2014.988198