## Thursday, June 25, 2015

### Pair Ranking Algorithm

require 'highline/import'
require "pp"
require 'rasam'

include Rasam

lambda { |ans| ans =~ /^-?\d+\$/ ? Integer(ans) : ans} ) do |q|
q.gather = ""
end

@pr = PairRank.new(options)
@saved_combinations = Array.new(@pr.combinations)
combinations = Array.new(@pr.combinations)

pair = combinations.shift

def get_user_choice_for(pair)

pair.each do |c|
say(c)

say(rationale)

rc = RationalChoice.new(pair, c, rationale)
@pr.make(rc)
end
end
end
end

loop do
p pair
get_user_choice_for(pair)
break if combinations.empty?
pair = combinations.shift
end

@pr.decisions.each do |d|
p d.to_s
end

p @pr.score_for('A')
p @pr.score_for('B')
p @pr.score_for('C')

def handle_ties(pair)

pair.each do |c|
say(c)

say(rationale)

rc = RationalChoice.new(pair, c, rationale)
@pr.make(rc)
end
end
end
end

loop do
p 'Handling a tie'
if @pr.tied_pair.empty?
break
else
handle_ties(@pr.tied_pair)

@pr.decisions.each do |d|
p d.to_s
end

p @pr.score_for('A')
p @pr.score_for('B')
p @pr.score_for('C')
p @pr.tied_pair

end
end