The planet Mars orbits around the Sun more slowly than the Earth does, because the Earth is nearer to the Sun. Every 2.2 years, the Earth in its faster orbit passes Mars, forming a temporary alignment of Sun-Earth-Mars called "Mars opposition". For a few weeks around opposition, Mars appears to move "backward" in the sky, as the Earth overtakes it. This is called "retrograde motion", and is simply due to the fact that we are observing Mars from a moving platform (the Earth).
This script tracks Mars for several months in 2005 as it executes a retrograde loop.
To run the script, simply save it to disk and unzip it, then open it from within KStars using "File|Run Script..." or Ctrl+R.