From fd7d3385a595bda57014bcf875149a10411049e5 Mon Sep 17 00:00:00 2001 From: Balthazar Wilson <wilsonba@etu.utc.fr> Date: Sun, 5 Nov 2023 17:05:39 +0100 Subject: [PATCH] fix: copeland --- comsoc/Copeland.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/comsoc/Copeland.go b/comsoc/Copeland.go index 4387e0f..b99c415 100644 --- a/comsoc/Copeland.go +++ b/comsoc/Copeland.go @@ -10,8 +10,8 @@ func CopelandSWF(p Profile) (count Count, err error) { if err != nil { return nil, err } - for alt1 := 0; alt1 < len(p); alt1++ { - for alt2 := alt1 + 1; alt2 < len(p); alt2++ { + for alt1 := 1; alt1 <= len(alts); alt1++ { + for alt2 := alt1 + 1; alt2 <= len(alts); alt2++ { score1, score2 := 0, 0 for _, pref := range p { if isPref(Alternative(alt1), Alternative(alt2), pref) { @@ -22,7 +22,9 @@ func CopelandSWF(p Profile) (count Count, err error) { } if score1 > score2 { count[Alternative(alt1)]++ + count[Alternative(alt2)]-- } else if score2 > score1 { + count[Alternative(alt1)]-- count[Alternative(alt2)]++ } } -- GitLab