Checking whether the player cannot see the AI

Thanks, that might be part of the solution. However, I also need to find out if there are any objects between the player and AI that are hiding it (i.e. the AI is behind a wall and the player cannot see it), which adds even more complications…I really hope there is some simpler way to do this than computing it all by myself.