This week, I spent most of my free time adding an NPC character to my ThreeJS game and have them walk towards me each time I move my own character.

I’m using the A* algorithm. Each time I move my own character, the NPC finds the shortest path to my character using this algorithm and then moves one step to my character.

As I’m already using a two-dimensional array to represent the game’s board, using the algorithm on this array helped me get it working. What I wasn’t prepared for was the amount of code needed to implement the algorithm and move the NPC across the board. Still, I managed to learn a thing or two more about TypeScript.

What’s next for my game? I’m not sure yet. There are so many things that I could be doing, such as adding attributes for my characters, both PC and NPC characters, and adding more elements for the map, like ancient ruins. My youngest is also designing skins for the playing character and the NPC, so they’re more than just coloured rectangles on the board.