how do I make the bot hunt for the player and if it catches him, the game ends?

Hi, can you help me? I tried to do it myself, but it didn’t work out. Тhe problem is that the bot has to walk through the corridors

how do I make the bot hunt for the player and if it catches him, the game ends?