I'm pretty sure things are partly based on time, partly based on castle damage.
Stop Signal might tell us... but the other person would be ja_kingy, who I believe dug into the code a bit in order to craft their 4 turn win, and thus probably knows some details behind the scenes.