Initial reference implementation of scoring algorithm

Untested.