Report method of breaking ties

This commit is contained in:
RunasSudo 2021-01-15 16:06:27 +11:00
parent 1e2f74e60b
commit d5db9b5df6
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 10 additions and 0 deletions

View File

@ -650,6 +650,7 @@ class BaseSTVCounter:
for tie in self.options['ties']:
result = tie.choose_lowest(tied)
if result is not None:
self.logs.append('A tie for last place was resolved ' + tie.adverb + ' against ' + result[0].name + '.')
return result
raise STVException('Unable to resolve tie')
@ -674,6 +675,7 @@ class BaseSTVCounter:
for tie in self.options['ties']:
result = tie.choose_highest(tied)
if result is not None:
self.logs.append('A tie for first place was resolved ' + tie.adverb + ' in favour of ' + result[0].name + '.')
return result
raise STVException('Unable to resolve tie')

View File

@ -31,6 +31,8 @@ class RequireInput(Exception): # pragma: no cover
class TiesPrompt:
"""Prompt the user to break ties"""
adverb = 'manually'
def __init__(self):
self.buffer = None
@ -83,6 +85,8 @@ class TiesBackwards:
all other tied candidates, if such a stage exists
"""
adverb = 'backwards'
def __init__(self, counter):
self.counter = counter
@ -113,6 +117,8 @@ class TiesForwards:
all other tied candidates, if such a stage exists
"""
adverb = 'forwards'
def __init__(self, counter):
self.counter = counter
@ -139,6 +145,8 @@ class TiesForwards:
class TiesRandom:
"""Break ties randomly, using the SHARandom deterministic RNG"""
adverb = 'randomly'
def __init__(self, seed):
self.random = SHARandom(seed)