Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I'm writing an iOS game (Using UIView), which has a randomly generated 2D city. I need attacking A.I., which will take an intelligent path to find the player (without colliding with buildings). Can someone point me in the right direction as to what kind of algorithms I would use to achieve this?

Edit: I've decided to use A*. I will create a grid on the map, test every grid intersection point, if that point is inside a building, I'll invalidate the point. The attacking A.I. player will then move from its current location to a valid grid point, which is closer to its goal (within a certain radius of its location).

1 Answer

0 votes
by (107k points)

There are many approaches you can use.

The classic algorithms here are Dijkstra's algorithm and A* search, which can guide an object from one location to another along the optimal path. These algorithms run by modeling the 2D world as a graph and then finding the shortest path from the object's start location to the destination location in that graph. These two algorithms are used broadly in AI and pathfinding, and I would strongly suggest investing the time to read more about them. 

You can also refer to the link here Pacman scent anti object pattern describes a cheap and effective approach.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...