This sounds a lot like a task of 2004 ICFPC Programming contest: ants, pheromone trails, only local vision, etc: https://web.archive.org/web/20060709155354/http://www.cis.up...
I can't see the rules of this challenge, but it sounds really darn close.