There’s always multiple ways to program something. In this case I’d might use a Boolean variable to keep track of which tombstone the ghost was facing.
Code:
Set "Is ghost going toward tombstone 1" to false.
While …
If ("Is ghost going toward tombstone 1") then
if (ghost is a least 2 meters from tombstone1) then
ghost move forward 0.5 meters
else
ghost turn to face tombstone2
ghost move forward 0.5 meters
set "Is ghost going toward tombstone 1" to false.
Else
if (ghost is a least 2 meters from tombstone2) then
ghost move forward 0.5 meters
else
ghost turn to face tombstone1
ghost move forward 0.5 meters
set "Is ghost going toward tombstone 1" to true
(But there are probably better ways to do this.)