0.87.0: Orbit Three, Gold and Riot identities, fair block rotation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,17 +33,17 @@ class PlanBaselineTest {
|
||||
}
|
||||
|
||||
private val day = 24 * hour
|
||||
private fun plans(rule: Boolean = true) = linkedMapOf(
|
||||
private fun plans(third: Boolean = true, blocks: Boolean = true) = linkedMapOf(
|
||||
"turns" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day),
|
||||
"finishTogether" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, noThirdInARow = rule),
|
||||
"dayParts" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, dayParts = parts, zone = zone, noThirdInARow = rule),
|
||||
"clash" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = rule),
|
||||
"everythingClashes" to extendSchedule(listOf(show("a", 2, 7, 22)), ScheduleCursor(), start, start + day, avoid = avoid, noThirdInARow = rule),
|
||||
"shuffle" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, shuffle = true, noThirdInARow = rule),
|
||||
"finishTogether" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, noThirdInARow = third, blockRotation = blocks),
|
||||
"dayParts" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, dayParts = parts, zone = zone, noThirdInARow = third, blockRotation = blocks),
|
||||
"clash" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
|
||||
"everythingClashes" to extendSchedule(listOf(show("a", 2, 7, 22)), ScheduleCursor(), start, start + day, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
|
||||
"shuffle" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, shuffle = true, noThirdInARow = third, blockRotation = blocks),
|
||||
"films" to extendSchedule(films, ScheduleCursor(), start, start + 5 * day, filmRestMs = 2 * day),
|
||||
"filmsClash" to extendSchedule(films + listOf(PoolSeries("a", "Show a", listOf(PoolEpisode("a", "src-a", EpisodeMark(1, 1), "Show a", 90 * minute)))), ScheduleCursor(), start, start + 3 * day,
|
||||
filmRestMs = day, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = rule),
|
||||
"topUp" to topUpPlan(extendSchedule(shows, ScheduleCursor(), start, start + 2 * day), ScheduleCursor(), shows, start + day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = rule),
|
||||
filmRestMs = day, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
|
||||
"topUp" to topUpPlan(extendSchedule(shows, ScheduleCursor(), start, start + 2 * day), ScheduleCursor(), shows, start + day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
|
||||
)
|
||||
|
||||
@Test fun everyNewProgrammeSaysWhy() {
|
||||
@@ -76,12 +76,18 @@ class PlanBaselineTest {
|
||||
// Taken from 0.81.4, before reasons were recorded.
|
||||
val expected = mapOf("turns" to "5cc4eee2cbfa29e6", "finishTogether" to "c357d2fae0d6a5df", "dayParts" to "764b7b7ac15a5b26", "clash" to "8d3c92c8c4beed8e",
|
||||
"everythingClashes" to "9f38ee7d889140c5", "shuffle" to "cee9b485bc705af2", "films" to "2f4f2786280d4589", "filmsClash" to "7fe17b8f3746e164", "topUp" to "40ce5b5f8e0e8ed3")
|
||||
// With the no-third-in-a-row rule off, planning is exactly as it was in 0.81.4.
|
||||
assertEquals(expected, plans(rule = false).mapValues { fingerprint(it.value) })
|
||||
// With the no-third-in-a-row rule and block rotation off, planning is exactly as it was in 0.81.4.
|
||||
assertEquals(expected, plans(third = false, blocks = false).mapValues { fingerprint(it.value) })
|
||||
}
|
||||
|
||||
@Test fun theRuleOnlyChangesPlansFromItsFirstEarlyRestart() {
|
||||
val before = plans(rule = false); val after = plans(rule = true)
|
||||
@Test fun theRulesOnlyChangeDayPartPlans() {
|
||||
val before = plans(third = false, blocks = false); val after = plans()
|
||||
// Plans without blocks are untouched by block rotation, and only change where a third in a row would have happened.
|
||||
for (name in listOf("turns", "everythingClashes", "films")) assertEquals(name, before.getValue(name)!!.entries.map { it.seriesId to it.mark }, after.getValue(name)!!.entries.map { it.seriesId to it.mark })
|
||||
}
|
||||
|
||||
@Test fun theNoThirdRuleOnlyChangesPlansFromItsFirstEarlyRestart() {
|
||||
val before = plans(third = false); val after = plans()
|
||||
for ((name, plan) in after) {
|
||||
val old = before.getValue(name)!!.entries; val new = plan!!.entries
|
||||
val firstEarly = new.indexOfFirst { "started its next round early" in it.why }
|
||||
|
||||
@@ -54,4 +54,20 @@ class RunLengthTest {
|
||||
assertFalse(paradox.mixes(show("b", 1).copy(title = "Buffy the Vampire Slayer")))
|
||||
assertFalse(paradox.mixes(show("s", 1).copy(title = "Supernatural")))
|
||||
}
|
||||
|
||||
@Test fun aBlockCarriesOnItsRotationFromDayToDay() {
|
||||
// Eight evening shows but only about four evening slots a day: each show must still get its turn across the week.
|
||||
val zone = java.time.ZoneId.of("Europe/London")
|
||||
val midnight = java.time.ZonedDateTime.of(2026, 11, 9, 0, 0, 0, 0, zone).toInstant().toEpochMilli()
|
||||
val day = (1..3).map { show("day$it", 50) }; val evening = (1..8).map { show("eve$it", 50).copy(episodes = show("eve$it", 50).episodes.map { e -> e.copy(durationMs = 60 * minute) }) }
|
||||
val parts = listOf(DayPart(20, 0, evening.map { it.title }), DayPart(0, 20, day.map { it.title }))
|
||||
var plan = extendSchedule(day + evening, ScheduleCursor(), midnight, midnight + 60 * minute, finishTogether = true, dayParts = parts, zone = zone)
|
||||
var all = plan.entries
|
||||
while (plan.endMs < midnight + 7 * 24 * 60 * minute) {
|
||||
plan = extendSchedule(day + evening, plan.tail, plan.endMs, plan.endMs + 60 * minute, finishTogether = true, dayParts = parts, zone = zone)
|
||||
all = all + plan.entries
|
||||
}
|
||||
val aired = all.map { it.seriesId }.toSet()
|
||||
assertTrue("every evening show airs: ${evening.map { it.id } - aired}", evening.all { it.id in aired })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user