Follow this link for a blog post on creating a maze (as an alternate form of game map) and then the follow up blog entry on converting a selected maze into JavaScript code ready to paste into a Ray casting project.
The chapter started the exploration of NPC behaviours with some straightforward methods that gave those sprites some added depth.
I wanted to explore some methods where the NPCs chase the player. The code I developed is for a slightly different game world so that it
could be kept simple - no need to invoke the challenge of ray casting if we can test the ideas in a less demanding scenario.
There is a blog post on this and the code can be downloaded from GitHub.
Read the chapter in my book Learn to Program with Games and JavaScript