There has been a certain amount of controversy about the rules for counting the votes because they are not actually that clear, and some interpretations of them lead to non-intuitive results. Here is what the rules say:
- If a user has 51% of the first-choice vote, that candidate will be declared the winner.
- If no user has 51% of the first-choice vote, we will begin using an Instant Runoff process. The user with the lowest tally for first-choice vote will be eliminated, and the second choice candidate on those ballots will be substituted as first choice. This process will continue (drop lowest candidate, reassign to next vote, tally again) until any user has 51% of the vote.
- If all ballots are exhausted and no candidate has 51% of the vote, we will return to the first round and award the election to the candidate with the most 1st choice votes.
The particular problem with this is what is meant by "51% of the vote." Suppose 35% of voters vote for A and no one else; 30% vote for B first and C second; 15% vote for C first and B second, and 20% vote for other candidates entirely. If A, B and C are the last three candidates in then C will be eliminated, giving B 45% of the original vote to A's 35%. But neither candidate has 51% of the vote, so under the last rule above the election will be awarded to A despite the fact that A is clearly less popular than either B or C.
The other way of looking at it is in this: if 100 people voted originally, then when only A and B remain, A has 35 votes and B has 45, so out of those 80 votes B has a clear majority and the election would be awarded to B (which is as it should be in my opinion). If this is the case though, the last rule quoted above will never come into operation unless the final result is a tie (or very nearly so).
Well, there is no substitute for looking at the code.
The first thing to note is that the procedure for deciding whether there's a winner (
has_majority) declares a result if any one candidate has strictly more than half of the total vote (i.e., not 51% as the rules say; I am guessing here that they meant to say "more than 50%").
The procedure for determining the winner seems to go like this:
- Sort every ballot paper into buckets (
vote_totals), one for each candidate, based on who currently appears in first choice on the ballot paper.
- Count the number of votes in each bucket and note the total number of votes in all buckets. If any candidate has more than half the total votes, that candidate is the winner.
- List the candidate or candidates with the least number of votes in their buckets. If that happens to be all the candidates (it's a dead heat) then cross off the first choice from every vote and go back to the start.
- Take all the votes out of the eliminated candidates' buckets and cross off the current first choice before going back to the start.
Most importantly, any ballot papers without a valid vote on them are not placed in any bucket and so take no further part in the election. Therefore the second scenario in my hypothetical example applies (i.e., B is elected).
The code doesn't actually mention what happens if this procedure fails to return a result, but it does display its internal workings to the LiveJournal official who counts the vote so that case can be handled manually.
The upshot of this is that putting me in first place on your ballot will not automatically let the troll candidate get in by default, provided you use the second and third place votes wisely.
If any perl experts beg to differ and would like to pronounce me wrong, please go ahead. :-)