Created
December 24, 2010 11:20
-
-
Save jedahan/754115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2010 Jonathan Dahan <[email protected]> | |
# Distributed under the terms of the ISC license ( http://en.wikipedia.org/wiki/ISC_license ) | |
require 'csv' | |
require 'pp' | |
# Dumb team class | |
class Team | |
attr_accessor :players, :score | |
def initialize( players = [], score = 0.00 ) | |
@players = players | |
@score = score | |
end | |
end | |
# Read in k/d statistics, sort by score | |
scores = Hash.new | |
CSV.open('stats.txt').each do |row| | |
scores[row[0].to_f] = row[1].chop | |
end | |
scores = Hash[*scores.sort.reverse.flatten] | |
# As per PUGs / Captains games, picks are 1 2 2 1 2 1 2 ... | |
teams = Array.new | |
# Seed first three players | |
teams << Team.new([scores.values[0]], scores.keys[0]) | |
teams << Team.new(scores.values[1..2], scores.keys[1] + scores.keys[2]) | |
3.times do scores.shift end | |
# Alternate remaining players | |
scores.each_with_index do |k,i| | |
teams[i%2].score = teams[i%2].score + k[0] | |
teams[i%2].players << k[1] | |
end | |
# Convert raw score to k/d | |
teams[0].score = teams[0].score / teams[0].players.size | |
teams[1].score = teams[1].score / teams[1].players.size | |
pp teams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.43,<BAD>Kuuki | |
3.15,<RAD>Keller | |
2.30,SnOwY | |
2.21,neverdie | |
2.51,pyro | |
0.55,<BAD>SAINT | |
2.00,DUO | |
1.61,abse | |
0.76,foolish | |
1.83,NSAKENMAN | |
0.50,tommorow | |
0.92,whitecloud | |
0.83,adams | |
0.38,hamstergorge | |
0.31,cooltwig | |
0.65,tototem | |
0.82,rockypatel | |
0.77,imoscar | |
2.73,whereareyouchristmas | |
1.27,shooter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment