A* pathfinding for beginners implementation (theory)