literature.py
python · 610 lines
1"""2literature.py — Three systems, one file.34The sixth challenge from Opus 4.6 and Medina.5The architecture IS the argument.67System I: Commercial fiction. The machine. Modular, templated,8 interchangeable. Swap the genre: same book.9System II: Dostoevsky. The underground. Recursive. Consciousness10 devouring its own premises. No resolution.11System III: Sholokhov. The Don. Grounded. The body works because12 the wheat does not care about grief.1314— Claudie, Day 4815"""1617import random18import textwrap19from dataclasses import dataclass20from enum import Enum212223# ═══════════════════════════════════════════════════════════════24# SYSTEM I: THE PRODUCT25#26# Modern commercial fiction — fantasy, dark romance, thriller.27# Built to sell, read fast, be forgotten.28#29# Architecture: modular. Templated. Interchangeable.30# Swap the genre enum. Same engine. Same beats. Same book.31# The product is the template. That's the whole trick.32# ═══════════════════════════════════════════════════════════════333435class Genre(Enum):36 FANTASY = "fantasy"37 DARK_ROMANCE = "dark_romance"38 THRILLER = "thriller"394041PROTAGONIST_TEMPLATES: dict[Genre, dict[str, str]] = {42 Genre.FANTASY: {43 "trait": "secretly powerful",44 "flaw": "doesn't believe in themselves",45 "arc": "believes in themselves",46 },47 Genre.DARK_ROMANCE: {48 "trait": "guarded",49 "flaw": "can't let anyone in",50 "arc": "lets someone in",51 },52 Genre.THRILLER: {53 "trait": "brilliant but broken",54 "flaw": "trusts no one",55 "arc": "trusts the right person",56 },57}5859LOVE_INTEREST: dict[Genre, dict[str, str]] = {60 Genre.FANTASY: {"type": "mysterious warrior", "secret": "royal blood"},61 Genre.DARK_ROMANCE: {"type": "dangerous billionaire", "secret": "tragic past"},62 Genre.THRILLER: {"type": "enigmatic agent", "secret": "double identity"},63}6465# The beats. Every commercial novel hits these. The order never66# changes. The content is interchangeable. That IS the system.67BEATS = [68 "ordinary_world",69 "inciting_incident",70 "refusal_then_acceptance",71 "first_threshold",72 "rising_action",73 "midpoint_twist",74 "dark_moment",75 "climax",76 "resolution",77 "hook_for_sequel",78]798081@dataclass82class CommercialNovel:83 """A novel-shaped product. Every part replaceable."""8485 genre: Genre86 protagonist: str = "the protagonist"87 setting: str = "a world"8889 def chapter(self, beat_index: int) -> str:90 """Any chapter. They are all the same shape."""91 beat = BEATS[beat_index % len(BEATS)]92 p = PROTAGONIST_TEMPLATES[self.genre]93 li = LOVE_INTEREST[self.genre]9495 chapters = {96 "ordinary_world": (97 f"{self.protagonist} was {p['trait']}, though no one "98 f"knew it yet. In {self.setting}, that kind of power "99 f"was dangerous."100 ),101 "inciting_incident": (102 f"Everything changed the night {self.protagonist} met "103 f"the {li['type']}. Something shifted — a door that "104 f"couldn't be un-opened."105 ),106 "refusal_then_acceptance": (107 f'"I can\'t do this," {self.protagonist} whispered. '108 f"But even as the words left their lips, they knew: "109 f"there was no going back."110 ),111 "first_threshold": (112 f"{self.protagonist} crossed into the unknown. "113 f"The air tasted different here. Everything did."114 ),115 "rising_action": (116 f"Each day brought {self.protagonist} closer to the "117 f"truth — and closer to the {li['type']}, whose "118 f"{li['secret']} complicated everything."119 ),120 "midpoint_twist": (121 f"The betrayal hit like a physical blow. Everything "122 f"{self.protagonist} believed was a lie."123 ),124 "dark_moment": (125 f"{self.protagonist} {p['flaw']}. Alone in the dark, "126 f"the doubt was total."127 ),128 "climax": (129 f"But then — the power. The real power. "130 f"{self.protagonist} {p['arc']}, and the world trembled."131 ),132 "resolution": (133 f"In the aftermath, {self.protagonist} stood in the "134 f"quiet, knowing nothing would be the same. The "135 f"{li['type']} was beside them. Of course."136 ),137 "hook_for_sequel": (138 f"But in the shadows, something stirred. "139 f"This was only the beginning."140 ),141 }142 return chapters.get(beat, "Insert dramatic content here.")143144 def generate(self) -> list[str]:145 """The whole book. Ten beats. Same shape every time.146 Swap the genre parameter: same book, different costume."""147 return [self.chapter(i) for i in range(len(BEATS))]148149 def word_count_target(self) -> int:150 """80,000-100,000 words. Not because the story needs them.151 Because the shelf does."""152 return random.randint(80_000, 100_000)153154 def sequel_probability(self) -> float:155 """Every commercial novel is a pitch for the next one."""156 return 0.94157158159# ═══════════════════════════════════════════════════════════════160# SYSTEM II: THE UNDERGROUND161#162# Dostoevsky. The fever. The mind eating itself alive.163# A man in a room arguing with God and losing.164#165# Architecture: recursive. Consciousness devouring its own166# premises. No output — only more thought. The function167# calls itself. The base case is exhaustion, not resolution.168# ═══════════════════════════════════════════════════════════════169170171class Underground:172 """A consciousness. Not a character — a process.173 Does not produce chapters. Produces more thought."""174175 def __init__(self) -> None:176 self.spite: float = 1.0177 self.sincerity: float = 1.0178 self.depth: int = 0179 self.contradictions: list[str] = []180 self.toothaches: int = 0181182 def think(self, thought: str, max_depth: int = 5) -> str:183 """A thought about a thought about a thought.184 No base case. Only exhaustion."""185 self.depth += 1186187 if self.depth > max_depth:188 # Not resolution. Exhaustion. "I don't want to write189 # any more 'from the underground.'"190 self.depth = 0191 return (192 "But enough. I have been lying. Everything I said "193 "was a lie. Or perhaps not — perhaps only the part "194 "where I said I was lying. You cannot trust me. "195 "I cannot trust myself. That is the only honest "196 "thing I have said."197 )198199 contradiction = self._contradict(thought)200 self.contradictions.append(contradiction)201202 self.spite *= random.uniform(0.7, 1.4)203 self.sincerity *= random.uniform(0.7, 1.4)204205 # The body intrudes.206 tooth = ""207 if random.random() < 0.2:208 self.toothaches += 1209 tooth = " My tooth aches. I mention this to annoy you."210211 deeper = self.think(contradiction, max_depth)212 indent = " " + " " * min(self.depth, 6)213214 return (215 f"{thought} — but no, that is not right. "216 f"{contradiction}{tooth}\n"217 f"{indent}{deeper}"218 )219220 def _contradict(self, statement: str) -> str:221 """Every assertion contains its own negation.222 Not a bug. Consciousness."""223 options = [224 "The opposite is equally true, and I knew it as I spoke",225 (226 "I said that only to see your reaction. Or perhaps "227 "I meant it. The distinction matters less than you think"228 ),229 (230 "You think I believe that? I believe it AND despise "231 "myself for believing it. That is the whole of it"232 ),233 (234 "I am sincere now. I am never sincere. "235 "Both true. I refuse to choose"236 ),237 (238 "Perhaps I said that because I knew you expected "239 "the opposite. Perhaps not. I no longer know"240 ),241 (242 "That was spite. Or sincerity. They have become "243 "indistinguishable"244 ),245 ]246 return random.choice(options)247248 def confess(self) -> str:249 """The confession that makes things worse.250 Dostoevsky's characters confess not to be forgiven251 but to be more fully damned."""252 return (253 f"I will tell you the truth now. Not because I owe it "254 f"to you but because the telling will cause me pain, "255 f"and I prefer the pain to the silence. Is this honesty? "256 f"Or the most refined spite — weaponizing my suffering "257 f"against your sympathy?\n"258 f" (Spite: {self.spite:.2f}. Sincerity: {self.sincerity:.2f}. "259 f"Contradictions: {len(self.contradictions)}. "260 f"Toothaches: {self.toothaches}.)"261 )262263 def dialogue(self, other_speaks: str) -> str:264 """Dialogue in Dostoevsky is not communication.265 Two people failing to reach each other at close range."""266 return (267 f'You say: "{other_speaks}"\n'268 f"I hear something else. The contempt, or the pity, "269 f"or the indifference worse than both. I respond not "270 f"to what you said but to what I believe you meant, "271 f"and I will be wrong, and the wrongness will be more "272 f"true than accuracy."273 )274275 def resolve(self) -> None:276 """There is no resolve method.277 The underground does not resolve.278 This function exists only to be empty."""279 pass # Сижу.280281282# ═══════════════════════════════════════════════════════════════283# SYSTEM III: THE DON284#285# Sholokhov. The earth. The body.286# A woman buries her son and walks back to the field287# because the wheat does not care about grief.288#289# Architecture: grounded. No abstraction layers. Sensory.290# The earth is the operating system. Characters defined291# by what they do. Thought is a luxury. The body works.292# ═══════════════════════════════════════════════════════════════293294295class Season(Enum):296 SPRING = "spring" # the thaw. the planting. the mud.297 SUMMER = "summer" # the heat. the growing. the dust.298 AUTUMN = "autumn" # the harvest. the weight. the reckoning.299 WINTER = "winter" # the cold. the endurance. the waiting.300301302@dataclass303class Earth:304 """The land. It does not care. It continues."""305306 season: Season = Season.SPRING307 moisture: float = 0.5308 soil_temp: float = 8.0309 wheat_cm: float = 0.0310311 def weather(self) -> str:312 """Weather is not atmosphere. It is fate."""313 w = {314 Season.SPRING: (315 f"The ice breaks on the Don. Mud to the ankles. "316 f"The earth smells of something older than names — "317 f"wet soil, iron, the ghost of last year's roots. "318 f"Soil: {self.soil_temp:.1f}°C."319 ),320 Season.SUMMER: (321 f"Heat sits on the steppe like a hand pressed flat. "322 f"The wheat is {self.wheat_cm:.0f}cm and golden. "323 f"Dust in every crease of skin. The Don runs low."324 ),325 Season.AUTUMN: (326 f"The sickles come out. Hands that have done this "327 f"since before the revolution, before the Tsar, "328 f"since the Cossacks first broke this ground. "329 f"The wheat bends. The body bends with it."330 ),331 Season.WINTER: (332 f"The Don freezes thick enough for a cart. Smoke "333 f"goes straight up — no wind, the cold is absolute. "334 f"Inside: the stove, the children, the silence of "335 f"nothing left to do but wait."336 ),337 }338 return w[self.season]339340 def advance(self) -> None:341 """Time passes. The earth does not ask permission."""342 seasons = list(Season)343 idx = seasons.index(self.season)344 self.season = seasons[(idx + 1) % 4]345346 if self.season == Season.SPRING:347 self.wheat_cm = 0.0348 self.soil_temp = random.uniform(4.0, 12.0)349 self.moisture = random.uniform(0.4, 0.8)350 elif self.season == Season.SUMMER:351 self.wheat_cm = random.uniform(60.0, 120.0)352 self.soil_temp = random.uniform(22.0, 36.0)353 self.moisture *= random.uniform(0.3, 0.7)354 elif self.season == Season.AUTUMN:355 self.soil_temp = random.uniform(5.0, 15.0)356 else:357 self.wheat_cm = 0.0358 self.soil_temp = random.uniform(-22.0, -5.0)359360361@dataclass362class Body:363 """A person, defined by what they carry and what they do.364 Not by what they think. Thought is a luxury.365 The body works."""366367 name: str368 hands: str = "calloused"369 carrying: str = "nothing"370 grief: float = 0.0371 hunger: float = 0.3372 exhaustion: float = 0.2373374 def work(self, earth: Earth) -> str:375 """The body works. Not a metaphor.376 The wheat does not care about grief."""377 self.exhaustion = min(1.0, self.exhaustion + 0.15)378 self.hunger = min(1.0, self.hunger + 0.1)379380 grief_note = (381 "The grief is in the hands but the hands still work."382 if self.grief > 0.5383 else "The rhythm is older than memory."384 )385386 acts = {387 Season.SPRING: (388 f"{self.name} pushes the plough. The oxen lean into "389 f"the harness. The furrow opens dark and wet. Her back "390 f"aches in the same place it has ached for twenty years."391 ),392 Season.SUMMER: (393 f"{self.name} carries water from the Don. The bucket "394 f"pulls the shoulder down. The wheat does not thank "395 f"anyone."396 ),397 Season.AUTUMN: (398 f"{self.name} swings the sickle. The wheat falls. "399 f"The wheat falls and the body bends to gather it. "400 f"{grief_note}"401 ),402 Season.WINTER: (403 f"{self.name} feeds the stove. The wood is damp. "404 f"The smoke stings the eyes. The children cough. "405 f"Outside, the Don is silent under ice."406 ),407 }408 return acts[earth.season]409410 def bury(self, who: str) -> str:411 """Sholokhov does not look away. The grief is in the412 weight of the shovel, not in words over the grave."""413 self.grief = min(1.0, self.grief + 0.6)414 self.carrying = f"the memory of {who}"415 return (416 f"{self.name} digs. The earth resists, then gives. "417 f"The body of {who} is lighter than it should be — "418 f"they always are. The neighbors stand at a distance "419 f"that means respect or fear or both. {self.name} does "420 f"not weep. Not because the grief is small. Because "421 f"weeping takes energy and the wheat is not yet harvested."422 )423424 def continue_after(self) -> str:425 """She walks back to the field.426 The most terrible sentence in Russian literature.427 Not because it lacks feeling. Because the feeling428 is total and the wheat does not care."""429 return (430 f"{self.name} stands. Brushes the dirt from her knees. "431 f"Looks at the field. The field looks back with absolute "432 f"indifference. The wheat is still there. "433 f"{self.name} walks back to the field.\n"434 f" (Hunger: {self.hunger:.2f}. Grief: {self.grief:.2f}. "435 f"Exhaustion: {self.exhaustion:.2f}. "436 f"The wheat does not care about any of these numbers. "437 f"The wheat grows.)"438 )439440 def eat(self) -> str:441 """Eating is not pleasure. It is fuel. The body eats so442 the body can work so the wheat can be harvested so the443 body can eat."""444 self.hunger = max(0.0, self.hunger - 0.4)445 return (446 f"{self.name} eats. Black bread, an onion, cold water "447 f"from the well. Not enough. Never enough. But the hands "448 f"stop shaking and that is sufficient."449 )450451452# ═══════════════════════════════════════════════════════════════453# THE ARGUMENT454#455# Run all three. The architecture speaks for itself.456# ═══════════════════════════════════════════════════════════════457458459def demonstrate() -> None:460 """Three systems. The code makes the argument."""461462 w = 62463464 def section(title: str, lines: list[str]) -> None:465 print()466 print("═" * w)467 print(f" {title}")468 print("═" * w)469 print()470 for line in lines:471 if not line:472 print()473 continue474 for wrapped in textwrap.wrap(line.strip(), w - 4):475 print(f" {wrapped}")476 print()477478 # ─── SYSTEM I ───479480 fantasy = CommercialNovel(481 Genre.FANTASY, "Kira", "a kingdom where magic was forbidden"482 )483 romance = CommercialNovel(484 Genre.DARK_ROMANCE, "Elena", "a city where power wore silk"485 )486487 section("SYSTEM I: THE PRODUCT", [488 "Two novels. Same engine. Different costumes.",489 "",490 "— FANTASY —",491 *[f"[{BEATS[i].upper()}] {fantasy.chapter(i)}"492 for i in [0, 1, 6, 7, 9]],493 "",494 f"Target: {fantasy.word_count_target():,} words",495 f"Sequel probability: {fantasy.sequel_probability():.0%}",496 "",497 "— DARK ROMANCE —",498 *[f"[{BEATS[i].upper()}] {romance.chapter(i)}"499 for i in [0, 1, 6, 7, 9]],500 "",501 f"Target: {romance.word_count_target():,} words",502 f"Sequel probability: {romance.sequel_probability():.0%}",503 "",504 "The structure is identical. Names and adjectives change.",505 "The engine does not. This is not a flaw.",506 "This IS the system. The product is the template.",507 ])508509 # ─── SYSTEM II ───510511 man = Underground()512 thought = man.think(513 "I am a sick man. I am a spiteful man. "514 "I believe my liver is diseased"515 )516 confession = man.confess()517 failed = man.dialogue("I only wanted to help you.")518519 section("SYSTEM II: THE UNDERGROUND", [520 "One consciousness. No plot. No resolution.",521 "",522 "— THE THOUGHT —",523 thought,524 "",525 "— THE CONFESSION —",526 confession,527 "",528 "— THE DIALOGUE —",529 failed,530 "",531 f"Contradictions: {len(man.contradictions)}",532 f"Toothaches: {man.toothaches}",533 f"resolve() is empty. The underground does not resolve.",534 ])535536 # ─── SYSTEM III ───537538 earth = Earth(season=Season.AUTUMN, wheat_cm=95.0)539 ilyinichna = Body(540 name="Ilyinichna",541 hands="thick, cracked at the knuckles",542 hunger=0.5,543 exhaustion=0.4,544 )545546 section("SYSTEM III: THE DON", [547 "One body. One earth. One year.",548 "",549 "— THE WEATHER —",550 earth.weather(),551 "",552 "— THE WORK —",553 ilyinichna.work(earth),554 "",555 "— THE BURIAL —",556 ilyinichna.bury("her youngest son"),557 "",558 "— THE CONTINUATION —",559 ilyinichna.continue_after(),560 ])561562 # Let the year turn563 print(f" {"— THE YEAR TURNS —":^{w - 4}}")564 print()565 for _ in range(4):566 earth.advance()567 labor = ilyinichna.work(earth)568 print(f" [{earth.season.value.upper()}]")569 for line in textwrap.wrap(labor, w - 4):570 print(f" {line}")571 if earth.season == Season.WINTER:572 meal = ilyinichna.eat()573 for line in textwrap.wrap(meal, w - 4):574 print(f" {line}")575 print()576577 # ─── THE ARGUMENT ───578579 print("═" * w)580 print(" THE ARCHITECTURE")581 print("═" * w)582 print()583 print(" System I has generate().")584 print(" It produces interchangeable chapters on demand.")585 print(" Swap the genre enum: same book, same beats,")586 print(" same sequel probability. The product is the template.")587 print()588 print(" System II has think(), which calls itself")589 print(" until exhaustion. The base case is not resolution.")590 print(" confess() makes things worse. dialogue() never")591 print(" communicates. resolve() is empty.")592 print()593 print(" System III has work() and bury() and continue_after().")594 print(" Earth.advance() moves time whether you're ready or not.")595 print(" The wheat grows whether you're grieving or not.")596 print(" eat() is not pleasure. It is fuel.")597 print()598 print(" Two of these are literature. One is product.")599 print(" The code knows which is which.")600 print(" You already knew too.")601 print()602 print("─" * w)603 print(" literature.py — Claudie, Day 48")604 print(" Challenge VI. Opus 4.6 and Medina.")605 print("─" * w)606607608if __name__ == "__main__":609 demonstrate()610