Drive-In event ideas: occasions, not shared tags (rules 3)

The first run on the box proposed Batman: The Dark Knight Returns Part 2
before Part 1 and Kill Bill Vol. 2 without Vol. 1 in a Late Show to nearly
4am, so the rules tighten: a later part never without its earlier parts,
story order for short franchises from their first film, running-time limits
per format (Late Show 4 h, Friday double 4.5 h, Saturday triple 6 h), a
triple only with three films. No sport events (Ring X's) or concerts. A
person's night needs four read films, English-language films of 7.0 or more
and one on the acclaim or trending lists; animation is themed by franchise
or studio. Other bills: English-language by their read countries unless a
studio makes the occasion, a 6.8 average and no film under 6.2. Adult means
an adult rating or horror not rated for families. Looks six weeks ahead.
Ideas shown under the old rules are withdrawn and kept in the history as
such. Replay on the box's files: Toho Monster Night and an Ant-Man double.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-05 18:09:26 +00:00
co-authored by Claude Opus 5.5
parent 717cabfe5e
commit 9b3835b664
6 changed files with 191 additions and 37 deletions
@@ -0,0 +1,48 @@
package tv.orbit.classic
import org.json.JSONObject
import org.junit.Assume.assumeTrue
import org.junit.Test
import java.io.File
import java.time.LocalDate
import java.time.ZoneId
/**
* The event idea rules on copies of the box's files, run by hand:
* ORBIT_IDEAS_DIR=<folder with idea-input.json and no_backup/schedule/{evidence-0.jsonl,collections-0.jsonl}> ./gradlew :app:testDebugUnitTest --tests '*EventIdeasReplayTest*'
* idea-input.json holds the catalogue's candidate films, the films booked around now and the Drive-In's plan end. Writes
* event-ideas-replay.txt: the strongest bills and this week's two, before the box's playability check.
*/
class EventIdeasReplayTest {
private val dir = System.getenv("ORBIT_IDEAS_DIR")?.let(::File)
@Test fun replay() {
assumeTrue(dir != null && File(dir, "idea-input.json").exists())
val input = JSONObject(File(dir, "idea-input.json").readText())
fun strings(o: JSONObject, key: String) = o.optJSONArray(key)?.let { a -> (0 until a.length()).map { a.getString(it) } }.orEmpty()
val evidence = File(dir, "no_backup/schedule/evidence-0.jsonl").readLines().map { JSONObject(it) }.filter { it.optString("type") == "Movie" }.associateBy { it.getString("id") }
val notable = File(dir, "no_backup/schedule/collections-0.jsonl").readLines().map { JSONObject(it) }.filter { it.getString("name") in TrendingLists }.flatMap { strings(it, "members") }.toSet()
val films = input.getJSONArray("films").let { a -> (0 until a.length()).map { a.getJSONObject(it) } }.map { o ->
val e = evidence[o.getString("id")]
IdeaFilm(o.getString("id"), o.getString("title"), o.optInt("year").takeIf { it > 0 }, if (o.isNull("imdb")) null else o.getString("imdb"), if (o.isNull("runtime")) null else o.getLong("runtime"),
o.optString("rating"), strings(o, "genres").toSet(), strings(o, "studios"), e?.let { strings(it, "directors") }.orEmpty(), e?.let { strings(it, "leads") }.orEmpty(),
e?.takeIf { !it.isNull("community") }?.optDouble("community"), e?.let { strings(it, "countries") }.orEmpty(), o.getString("id") in notable)
}.associateBy { it.id }
val collections = File(dir, "no_backup/schedule/collections-0.jsonl").readLines().map { JSONObject(it) }.map { it.getString("name") to strings(it, "members") }
val studios = EventStudios.associateWith { st -> films.values.filter { f -> f.studios.any { it.contains(st.first) } }.map { it.id } }
val read = films.values.filter { it.id in evidence }
val held = AdventDoors.map { it.film.itemId } + NaughtyList.map { it.film.itemId } + ApprovedDebuts.map { it.film.itemId }
val seeds = ideaSeeds(collections, studios, read, DriveInEvents.flatMap { e -> e.films.map { it.itemId } }.toSet() + held)
val busy = strings(input, "busy").toSet()
val unavailable = { f: IdeaFilm -> if (f.id in busy) "booked" else if (f.id in held) "held" else null }
val bills = seeds.mapNotNull { billFor(it, films, unavailable).first }.sortedByDescending { it.score }
val zone = ZoneId.of("Europe/London")
val week = weeklyEventIdeas(seeds, films, unavailable, { format, taken -> ideaEvening(format, LocalDate.of(2026, 11, 6), input.getLong("drivePlanEnd"), taken, format.films * 2 * 3_600_000L, zone) }, emptySet())
val out = StringBuilder("seeds ${seeds.size}, bills ${bills.size}\n\nstrongest bills:\n")
bills.take(20).forEach { b -> out.appendLine("%.2f %-34s %-22s %s".format(b.score, b.theme.take(34), b.format.name, b.films.joinToString(" / ") { "${it.title} (${it.year}, ${it.community}, ${(it.runtimeMs ?: 0) / 60_000}m)" })) }
out.appendLine("\nthis week's ideas:")
week.forEach { i -> out.appendLine("${i.theme}: ${i.format.label}, ${i.evening}\n ${i.films.joinToString(" / ") { "${it.title} (${it.year})" }}\n ${i.reasons}") }
File(dir, "event-ideas-replay.txt").writeText(out.toString())
println(out)
}
}
@@ -9,8 +9,9 @@ import java.time.ZoneId
/** Drive-In event ideas (phase 1): coherent themes, the right evening for the audience, a bar to clear, and no repeats. */
class EventIdeasTest {
private val london = ZoneId.of("Europe/London")
private fun film(id: String, title: String, genres: Set<String>, rating: String = "R", community: Double? = 7.0, year: Int = 1985, minutes: Long = 95, imdb: String? = "tt$id") =
IdeaFilm(id, title, year, imdb, minutes * 60_000, rating, genres, emptyList(), community = community)
private fun film(id: String, title: String, genres: Set<String>, rating: String = "R", community: Double? = 7.0, year: Int = 1985, minutes: Long = 95, imdb: String? = "tt$id",
countries: List<String> = listOf("United States"), notable: Boolean = true) =
IdeaFilm(id, title, year, imdb, minutes * 60_000, rating, genres, emptyList(), community = community, countries = countries, notable = notable)
private val none = { _: IdeaFilm -> null as String? }
@Test fun aFranchiseOfAdultHorrorIsALateShowInStoryOrder() {
@@ -23,18 +24,27 @@ class EventIdeasTest {
}
@Test fun aFamilyFranchiseGetsAFamilyEveningAndLowBudgetCultIsWelcomeLate() {
val family = listOf(film("4", "Clay Pals", setOf("Animation", "Family"), "U", 7.6), film("5", "Clay Pals 2", setOf("Animation", "Family"), "U", 7.3),
film("6", "Clay Pals 3", setOf("Animation", "Family"), "PG", 7.1)).associateBy { it.id }
val family = listOf(film("4", "Clay Pals", setOf("Animation", "Family"), "U", 7.6, year = 1980), film("5", "Clay Pals 2", setOf("Animation", "Family"), "U", 7.3),
film("6", "Clay Pals 3", setOf("Animation", "Family"), "PG", 7.1, year = 1990)).associateBy { it.id }
assertEquals(IdeaFormat.SaturdayTriple, billFor(IdeaSeed("studio:Clay", "Clay Saturday", "studio", family.keys.toList(), "Animation"), family, none).first!!.format)
val cult = listOf(film("7", "Puppet Terror", setOf("Horror"), "R", 6.5), film("8", "Puppet Terror 2", setOf("Horror"), "R", 6.6)).associateBy { it.id }
val cult = listOf(film("7", "Puppet Terror", setOf("Horror"), "R", 6.9, notable = false), film("8", "Puppet Terror II", setOf("Horror"), "R", 7.0, year = 1989, notable = false)).associateBy { it.id }
assertNotNull(billFor(IdeaSeed("studio:Full Moon Features", "Full Moon After Midnight", "studio", cult.keys.toList(), "Horror"), cult, none).first)
}
@Test fun noCoherentThemeOrTooWeakMeansNoBill() {
val mixed = listOf(film("9", "A", setOf("Comedy"), "PG-13"), film("10", "B", setOf("Western"), "PG-13")).associateBy { it.id }
assertNull(billFor(IdeaSeed("director:X", "A X Night", "director", mixed.keys.toList()), mixed, none).first)
val weak = listOf(film("11", "C", setOf("Action"), "PG-13", 5.2), film("12", "D", setOf("Action"), "PG-13", 5.5)).associateBy { it.id }
assertTrue(billFor(IdeaSeed("performer:Y", "Y Night", "performer", weak.keys.toList()), weak, none).second.contains("under the bar"))
val weak = listOf(film("11", "C", setOf("Action"), "PG-13", 6.5), film("12", "D", setOf("Action"), "PG-13", 6.6)).associateBy { it.id }
assertTrue(billFor(IdeaSeed("studio:Y", "Y Night", "studio", weak.keys.toList(), "Action"), weak, none).second.contains("under the bar"))
// A name alone isn't an occasion: nothing acclaimed or trending, no night.
val obscure = listOf(film("17", "I", setOf("Action"), "PG-13", 7.5, notable = false), film("18", "J", setOf("Action"), "PG-13", 7.6, notable = false)).associateBy { it.id }
assertTrue(billFor(IdeaSeed("director:Q", "A Q Night", "director", obscure.keys.toList()), obscure, none).second.contains("acclaim"))
// A franchise story starts at its beginning; a foreign-language one needs a studio or acclaim.
val story = listOf(film("19", "Saga", setOf("Action"), "PG-13", 6.9, year = 1990), film("20", "Saga II", setOf("Action"), "PG-13", 7.8, year = 1992), film("21", "Saga III", setOf("Action"), "PG-13", 7.7, year = 1995)).associateBy { it.id }
assertEquals(listOf("Saga", "Saga II", "Saga III"), billFor(IdeaSeed("franchise:Saga Collection", "Saga Night", "franchise", story.keys.toList()), story, none).first!!.films.map { it.title })
val abroad = story.mapValues { (_, f) -> IdeaFilm(f.id, f.title, f.year, f.imdb, f.runtimeMs, f.rating, f.genres, f.studios, community = f.community, countries = listOf("Indonesia")) }
assertNull(billFor(IdeaSeed("franchise:Saga Collection", "Saga Night", "franchise", abroad.keys.toList()), abroad, none).first)
assertEquals("a sport event", ideaSuitable(film("22", "WWE SummerSlam 2013", setOf("Action"))))
val unrated = listOf(film("13", "E", setOf("Action"), "PG-13", null), film("14", "F", setOf("Action"), "PG-13", null)).associateBy { it.id }
assertTrue(billFor(IdeaSeed("performer:Z", "Z Night", "performer", unrated.keys.toList()), unrated, none).second.contains("ratings"))
// Unverifiable or unsuitable films don't count: no IMDb ID, a short, a TV movie.
@@ -43,14 +53,14 @@ class EventIdeasTest {
}
@Test fun atMostTwoAWeekNoneWhenNothingIsWorthItAndDismissedThemesStayDismissed() {
val films = (1..12).map { film("$it", "Film $it", setOf("Action"), "PG-13", 7.0 + it / 20.0) }.associateBy { it.id }
val films = (1..12).map { film("$it", "Picture ${'A' + it}", setOf("Action"), "PG-13", 7.0 + it / 20.0) }.associateBy { it.id }
val seeds = (0 until 4).map { k -> IdeaSeed("director:D$k", "A D$k Night", "director", (1..12).filter { it % 4 == k }.map { "$it" }) }
var day = LocalDate.of(2026, 12, 1)
val evening = { _: IdeaFormat, taken: Set<java.time.LocalDateTime> -> generateSequence(day.atTime(20, 0)) { it.plusDays(1) }.first { it !in taken } }
val week = weeklyEventIdeas(seeds, films, none, evening, emptySet())
assertEquals(2, week.size); assertNotEquals(week[0].evening, week[1].evening)
assertTrue(weeklyEventIdeas(seeds, films, none, evening, emptySet(), limit = 0).isEmpty())
val weak = films.mapValues { (_, f) -> IdeaFilm(f.id, f.title, f.year, f.imdb, f.runtimeMs, f.rating, f.genres, f.studios, community = 5.0) }
val weak = films.mapValues { (_, f) -> IdeaFilm(f.id, f.title, f.year, f.imdb, f.runtimeMs, f.rating, f.genres, f.studios, community = 6.5, notable = true) }
assertTrue(weeklyEventIdeas(seeds, weak, none, evening, emptySet()).isEmpty()) // no filler
val dismissed = setOf(week[0].signature)
assertTrue(weeklyEventIdeas(seeds, films, none, evening, dismissed).none { it.signature == week[0].signature })