Permalink
Browse files

fixed tallying of IRV to be consistent with allowing skipping of one …

…rank
  • Loading branch information...
Ben Adida Ben Adida
Ben Adida authored and Ben Adida committed Nov 6, 2009
1 parent 6911fca commit c9aa495cf29a507e603a7d317ba62d2031e0eaaf
Showing with 10 additions and 3 deletions.
  1. +10 −3 tallydata.py
View
@@ -24,7 +24,11 @@ def go_next_choice(self, choice_to_cancel):
self.__current_index += 1
if self.current_choice == None:
- self.exhausted = True
+ # try incrementing one more try, since you can skip one
+ self.__current_index += 1
+
+ if self.current_choice == None:
+ self.exhausted = True
@property
def current_choice(self):
@@ -41,7 +45,10 @@ def current_choice(self):
def reset(self):
self.__current_index = 0
- self.exhausted = (self.current_choice == None)
+ if self.current_choice == None:
+ self.__current_index = 1
+ if self.current_choice == None:
+ self.exhausted = True
@classmethod
def tally(cls, question, ballots):
@@ -79,7 +86,7 @@ def tally(cls, question, ballots):
lowest_count = min([tally for tally in candidate_tallies if tally is not None])
lowest_count_index = candidate_tallies.index(lowest_count)
eliminated.append(lowest_count_index)
- #print "eliminating candidate %s with count %s" % (lowest_count_index, lowest_count)
+ # print "eliminating candidate %s with count %s" % (lowest_count_index, lowest_count)
for b in ballots:
b.go_next_choice(lowest_count_index)

0 comments on commit c9aa495

Please sign in to comment.