Zombies in D&D have changed many times. In 5e zombies have 3 intelligence and 6 wisdom. Stat-wise makes them smarter than many animals and about as wise as an ogre or a cyclops.
In the back of the DMG on page 282 there is even an optional NPC zombie-template:
+1 Str, +2 Con, -6 INT, -4 WIS -4 CHA. Features: Undead fortitude; immune to poison damage; can't be poisoned; darkvision 60ft.; can't speak but understands the languages it knew in life
This suggests a zombie could 'roll' an ability as high as 12 intelligence &/or 14 wisdom / charisma. That is smarter than most living folks! Why is this all relevant?
The situation: The PC group outruns / outsmarts some undead, giving them a safe vantage point thanks to a cliff / wall / net / barrier situation. The now-safe adventurers attack via ranged weapons (cantrips, sling stones... dropping bricks... whatever). What will the zombies do? In film and television there are many options. Some will simply stay where they are and allow their meaningless non-lives to be ended. Yet other shows present zombies as well programmed machines that shamble away, possibly run. Some movies, like WWZ, have their undead change battle tactics on the fly just for plot (hole) development. Zombie tactical options and strategies are, in fact, as endless as they are mindless. But what would a 5e D&D zombie do? Early editions solved this problem as zombies were listed as having zero intelligence points or 'non intelligent'. I know that a 5e D&D skeleton is written up as having some vestigial memory of a previous life and can carry out behaviour accordingly (example from memory: humanoids had attended a ball whilst living - their (un)dead versions may still be dancing). It is also possible that a zombie might attune to a headband of intellect and suddenly be smarter than nearly any person that has ever lived. One could argue that a brilliant zombie could suddenly gain a death wish - as it became so keenly aware of its horrid existence with such little wisdom for 'will to live'. No idea.
The Question: Does a 5e D&D zombie have any hint, mention &/or (prime) directive for self preservation - assuming no specific orders from their master?
There is this possibly related question. I read it a few times, it is brilliant - but it does not answer this question.
My thanks in advance, let me know if I have missed something.