Pseudo code for the Thorney devil.