def exclude_lowest()

in pysteve/lib/plugins/stv.py [0:0]


def exclude_lowest(candidates):
  ### use: ahead = len(candidates) ??
  ahead = 1000000000.  # greater than any possible candidate.ahead
  rand = 1.1  # greater than any possible candidate.rand
  which = None
  used_rand = False

  random.shuffle(candidates)
  
  for c in candidates:
    if c.status == HOPEFUL or c.status == ALMOST:
      if c.ahead < ahead:
        ahead = c.ahead
        rand = c.rand
        which = c
        use_rand = False
      elif c.ahead == ahead:
        use_rand = True
        if c.rand < rand:
          rand = c.rand
          which = c

  if use_rand:
    debug.append('Random choice used!')

  assert which
  which.eliminate()