diff options
Diffstat (limited to 'core/scoring')
| -rw-r--r-- | core/scoring/proximity.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/scoring/proximity.go b/core/scoring/proximity.go new file mode 100644 index 0000000..f765aa7 --- /dev/null +++ b/core/scoring/proximity.go @@ -0,0 +1,31 @@ +package scoring + +import "math" + +func CalculateProximity(pos1, pos2 []int) float64 { + var score float64 + i, j := 0, 0 + + for i < len(pos1) && j < len(pos2) { + p1 := pos1[i] + p2 := pos2[j] + + dist := math.Abs(float64(p1 - p2)) + + if dist == 1 { + score += 15.0 + } else if dist <= 5 { + score += 5.0 + } else if dist <= 15 { + score += 1.0 + } + + if p1 < p2 { + i++ + } else { + j++ + } + } + + return score +} |
