Modified evil algorithm for ties

just need to run against test driver and work out few bugs