Add tiebreak analyzer

This commit is contained in:
ricola 2026-01-10 19:00:26 -06:00
parent 08fe4163bc
commit d429c16a9e

17
mj.rb
View file

@ -65,6 +65,23 @@ class MajorityJudgment
return MajorityJudgment.new(counta) <=> MajorityJudgment.new(countb)
end
def break_tie(other)
rounds = [ ]
s = MajorityJudgment.new(self.count.dup)
o = MajorityJudgment.new(other.count.dup)
rounds << [s, o]
while s.mj == o.mj and not s.mj == 0
new_s_count = s.count.dup
new_o_count = o.count.dup
new_s_count[s.mj] = new_s_count[s.mj] - 1
new_o_count[o.mj] = new_o_count[o.mj] - 1
s = MajorityJudgment.new(new_s_count)
o = MajorityJudgment.new(new_o_count)
rounds << [s, o]
end
return rounds
end
def to_s
puts "#{@count}: {M=>#{self.mj}, P=>#{self.proponents}, O=>#{self.opponents}}"
end