The movement of the AI ​​in a game based on chips

I have tried to have My AI follow my route A * in the grid. The problem is that it deviates and does not move very well along the way. I currently have it to move it only to the left and above.

My intention is that the character go to the center of the cells of the Path and repeat until the end.

void AIEnemy :: AutoMotion (Gridspot & grid)
{
std :: pair ecn = getNodePosition ();

                std :: reverse (grid.Path.begin (), grid.Path.end ());
for (automatic path: grid.Path)
{
if (path.node.first == ecn.first)
{
if (rect.getPosition (). and! = path.rectCenter.y)
rect.move (0, -5);
break;
}



if (path.node.first <ecn.first &&path.node.second == ecn.second)
{

if (right! = path.rectCenter.x)
movetoThe (e_left);
break;
}

}

my question is how can I make the character of AI move on its own and alter its direction towards a goal.