They are mostly based on luck. You can take a look at the source code to get an idea what those endings are. ;-)