Pledge algorithm

I understand what you mean by creating a bot that automatically finds its way to a certain location, so I have the following suggestion:
1 my solution (it not good ):

2 scratch solution (i try to make but it too lag ):