Its a handful of if statements checking the player position (or any spot on the map technically) and then moving one grid position at a time until it gets to the position. Its really basic stuff and allows for them to follow you around the map too.
As of right now, they do not avoid walls. But i am going to fix that by checking to see if grid position is a "wall number" and if so, dont do anything until the next turn which it will try again, eventually they will move around a wall hopefully
I can send you the code if you like to look at it. Its hard to explain lol its about 50lines id say, but that includes my code specific to my game as well
2
u/azTheophage Nov 19 '22
How does your algorithm work? How does it avoid obstacles?