magarena/scripts/score_card.awk

49 lines
760 B
Awk
Raw Normal View History

2012-05-18 19:53:11 -07:00
#!/usr/bin/awk -f
# read a list of decks in chronological order and produce a score for each card that appears
# skip comments
/^#/ {
next
prev = ""
}
2013-02-14 21:45:39 -08:00
/^\/\// {
next
prev = ""
}
{
# decay of scores
if (FILENAME != prev) {
for (i in score) {
score[i] = 0.95 * score[i]
}
prev = FILENAME
}
2013-02-14 21:45:39 -08:00
# to normalize mwDeck format
gsub("\\[.*\\]", "")
gsub("SB:", "")
gsub("^ *", "")
2013-02-14 22:23:21 -08:00
gsub(" +", " ")
s = gensub("^([0-9]*) ", "\\1|", "g", $0)
#print s
split(s, tok, "|")
#print "|"tok[1]"|"
cnt = tok[1]
gsub("|","",tok[2])
#print "|"tok[2]"|"
name = tok[2]
score[name] += cnt
}
END {
for (i in score) {
print score[i] "\t" i
}
}