From ab8ebb1832388455faef2cd860e4b6ca2d7d7e0c Mon Sep 17 00:00:00 2001 From: "Igor S. Gerasimov" Date: Sat, 8 Jul 2023 18:30:31 +0900 Subject: [PATCH] Fast no-blocking score --- Icfpc2023/Scoring.fs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Icfpc2023/Scoring.fs b/Icfpc2023/Scoring.fs index 11a0f9c..623b1f8 100644 --- a/Icfpc2023/Scoring.fs +++ b/Icfpc2023/Scoring.fs @@ -26,6 +26,12 @@ let private CalculateAttendeeScore (musicians: Musician[]) (attendee: Attendee): else CalculateAttendeeMusicianScore attendee musician ) +let private CalculateAttendeeNoBlockingScore (musicians: Musician[]) (attendee: Attendee): Score = + Seq.indexed musicians + |> Seq.sumBy(fun (i, musician) -> + CalculateAttendeeMusicianScore attendee musician + ) + let CalculateScore(problem: Problem) (solution: Solution): Score = let musicians = problem.Musicians @@ -33,3 +39,11 @@ let CalculateScore(problem: Problem) (solution: Solution): Score = |> Seq.map(fun(p, i) -> { Instrument = i; Location = p }) |> Seq.toArray problem.Attendees |> Array.sumBy(CalculateAttendeeScore musicians) + +let CalculateNoBlockingScore(problem: Problem) (solution: Solution): Score = + let musicians = + problem.Musicians + |> Seq.zip solution.Placements + |> Seq.map(fun(p, i) -> { Instrument = i; Location = p }) + |> Seq.toArray + problem.Attendees |> Array.sumBy(CalculateAttendeeNoBlokingScore musicians)