Make special mechanics essential in postcard and story puzzles

This commit is contained in:
Hadrian Burkhardt
2026-11-14 10:10:36 +01:00
parent b19295472d
commit fc71accb38
11 changed files with 736 additions and 40 deletions
+41 -7
View File
@@ -60,11 +60,19 @@
"before": "The causeway has disappeared beneath the tide. At the harbour steps, a little boat knocks softly against its rope.\n\nFirst, the store. The brass key turns, and you find two oars, a bailer, and an oilskin folded over the toolbox. Your name is chalked on the lid.\n\nYou carry them down to the steps. In the notebook, rain has blurred the boat's outline, but Gran's mark beside the sheltered landing is clear.\n\nYou set the lantern on a dry step and smooth the page with your palm.", "before": "The causeway has disappeared beneath the tide. At the harbour steps, a little boat knocks softly against its rope.\n\nFirst, the store. The brass key turns, and you find two oars, a bailer, and an oilskin folded over the toolbox. Your name is chalked on the lid.\n\nYou carry them down to the steps. In the notebook, rain has blurred the boat's outline, but Gran's mark beside the sheltered landing is clear.\n\nYou set the lantern on a dry step and smooth the page with your palm.",
"after": "The little boat is sound. You bail out the rainwater and settle the toolbox beneath the seat. The oilskin keeps the spray off it. Your lantern hangs low in the bow.\n\nThe knot refuses your first impatient tug.\n\nYou stop. Find the loose loop. Try again.\n\nIt opens so easily that you laugh.\n\nYou row towards the landing Gran marked. Behind you, the harbour steps grow small. Ahead, your light moves across the dark water, a little farther with every stroke.", "after": "The little boat is sound. You bail out the rainwater and settle the toolbox beneath the seat. The oilskin keeps the spray off it. Your lantern hangs low in the bow.\n\nThe knot refuses your first impatient tug.\n\nYou stop. Find the loose loop. Try again.\n\nIt opens so easily that you laugh.\n\nYou row towards the landing Gran marked. Behind you, the harbour steps grow small. Ahead, your light moves across the dark water, a little farther with every stroke.",
"picture": "0001000000110000011100001000111111101111101000001", "picture": "0001000000110000011100001000111111101111101000001",
"clues": "3,9", "clues": "48",
"areas": "0,3,5,2;3,1,3,3;2,2,4,4", "areas": "0,3,5,2;3,1,3,3;2,2,4,4",
"illustrationAsset": "assets/artwork/little-boat-vignette-v1.png", "illustrationAsset": "assets/artwork/little-boat-vignette-v1.png",
"id": "boat", "id": "boat",
"chapterId": "harbour" "chapterId": "harbour",
"mechanics": {
"omittedRow": 0,
"omittedColumn": 4,
"lantern": [
2,
42
]
}
}, },
{ {
"chapter": "II · Across the tide", "chapter": "II · Across the tide",
@@ -86,11 +94,20 @@
"before": "You tie the boat at the landing and lift out the toolbox. Beyond the reeds, a stream runs fast with the last of the storm water.\n\nYou once tried to jump this stream. You lost a boot. Gran carried you home, complaining cheerfully that you weighed as much as a sack of coal.\n\nTonight, the old bridge is welcome. You can just make out its rail beyond the reeds.\n\nGran drew the crossing in her notebook long before the storm. You hold up the lantern and compare the surviving lines.", "before": "You tie the boat at the landing and lift out the toolbox. Beyond the reeds, a stream runs fast with the last of the storm water.\n\nYou once tried to jump this stream. You lost a boot. Gran carried you home, complaining cheerfully that you weighed as much as a sack of coal.\n\nTonight, the old bridge is welcome. You can just make out its rail beyond the reeds.\n\nGran drew the crossing in her notebook long before the storm. You hold up the lantern and compare the surviving lines.",
"after": "The bridge is intact. You cross with the toolbox in one hand and the lantern in the other. Water hurries beneath the boards.\n\nOn the far bank, a bootprint points uphill. Beside it is the round mark of Gran's walking stick.\n\nShe has been this way already, testing the ground, carrying the oil. You set your foot beside hers.\n\nIt is a smaller print than you remember.\n\nYou lift the toolbox again and follow the path towards the bell.", "after": "The bridge is intact. You cross with the toolbox in one hand and the lantern in the other. Water hurries beneath the boards.\n\nOn the far bank, a bootprint points uphill. Beside it is the round mark of Gran's walking stick.\n\nShe has been this way already, testing the ground, carrying the oil. You set your foot beside hers.\n\nIt is a smaller print than you remember.\n\nYou lift the toolbox again and follow the path towards the bell.",
"picture": "0000000011111011000111000001100000111111110000000", "picture": "0000000011111011000111000001100000111111110000000",
"clues": "15,33", "clues": "13",
"areas": "2,1,3,5;0,2,5,3;2,3,2,2", "areas": "2,1,3,5;0,2,5,3;2,3,2,2",
"illustrationAsset": "assets/artwork/stone-bridge-vignette-v1.png", "illustrationAsset": "assets/artwork/stone-bridge-vignette-v1.png",
"id": "bridge", "id": "bridge",
"chapterId": "harbour" "chapterId": "harbour",
"mechanics": {
"omittedRow": 4,
"omittedColumn": 5,
"trail": [
7,
14,
21
]
}
}, },
{ {
"chapter": "II · Across the tide", "chapter": "II · Across the tide",
@@ -112,11 +129,19 @@
"before": "Gran opens the tower door before you knock.\n\n“There you are. Come in out of that wind.”\n\nHer hands are cold round yours. She notices the lantern, touches the cloth on its handle, and smiles.\n\n“I hoped you'd bring that one.”\n\nThe tower is sound. The clockwork that turns the beacon is not. A loose gear has brought it to a stop.\n\nYou set the toolbox between you. Gran spreads a cloth on the bench, and together you lay out the parts beside her drawing.", "before": "Gran opens the tower door before you knock.\n\n“There you are. Come in out of that wind.”\n\nHer hands are cold round yours. She notices the lantern, touches the cloth on its handle, and smiles.\n\n“I hoped you'd bring that one.”\n\nThe tower is sound. The clockwork that turns the beacon is not. A loose gear has brought it to a stop.\n\nYou set the toolbox between you. Gran spreads a cloth on the bench, and together you lay out the parts beside her drawing.",
"after": "The gear fits. You turn the mechanism slowly by hand. Its teeth meet the next wheel, and a small, steady ticking fills the room.\n\nGran stops what she is doing.\n\n“Your grandfather could hear that from the bottom stair. He always knew when it needed oil.”\n\nFor a while, you both listen.\n\nThen she sets the catch to hold the wheels still until the lamp is ready. She hands you a clean cloth.\n\n“Come on. Let's see what the storm has done to the glass.”", "after": "The gear fits. You turn the mechanism slowly by hand. Its teeth meet the next wheel, and a small, steady ticking fills the room.\n\nGran stops what she is doing.\n\n“Your grandfather could hear that from the bottom stair. He always knew when it needed oil.”\n\nFor a while, you both listen.\n\nThen she sets the catch to hold the wheels still until the lamp is ready. She hands you a clean cloth.\n\n“Come on. Let's see what the storm has done to the glass.”",
"picture": "0010100011111011000110101010110001101111100010100", "picture": "0010100011111011000110101010110001101111100010100",
"clues": "2,4,9,10,24,43", "clues": "5,14,20,25,30,31,32,43,46",
"areas": "2,3,3,3;1,3,5,3;1,2,4,3", "areas": "2,3,3,3;1,3,5,3;1,2,4,3",
"illustrationAsset": "assets/artwork/missing-gear-vignette-v1.png", "illustrationAsset": "assets/artwork/missing-gear-vignette-v1.png",
"id": "gear", "id": "gear",
"chapterId": "tower" "chapterId": "tower",
"mechanics": {
"omittedRow": 1,
"omittedColumn": 2,
"lantern": [
33,
1
]
}
}, },
{ {
"chapter": "III · The last light", "chapter": "III · The last light",
@@ -142,7 +167,16 @@
"areas": "1,3,4,2;0,3,2,2;2,2,4,2", "areas": "1,3,4,2;0,3,2,2;2,2,4,2",
"illustrationAsset": "assets/artwork/lighthouse-vignette-v1.png", "illustrationAsset": "assets/artwork/lighthouse-vignette-v1.png",
"id": "lighthouse", "id": "lighthouse",
"chapterId": "tower" "chapterId": "tower",
"mechanics": {
"omittedRow": 1,
"omittedColumn": 1,
"trail": [
8,
9,
10
]
}
}, },
{ {
"chapter": "III · The last light", "chapter": "III · The last light",
@@ -69,12 +69,20 @@
"before": "The kitchen was warm.\n\nAfter everything in the hall, that nearly broke me. A stove. A cloth over the bread. Someone's apron on a hook. I put the pumpkin on the table and held my hands towards the heat.\n\nApple cakes stood on a rack. Dust softened their edges, but heat was still rising from them.\n\n“I made those,” Iris said. “That evening. Sometimes I come in and think they must be ready to eat.”\n\nShe turned one over. It tapped the plate like a stone.\n\nBeside the stove was a beeswax candle, wrapped in a recipe. Lydia had written in the margin: One flame. One shadow. Count again before opening a door.\n\nI spread the paper beneath the lamp. The fold ran through a diagram of the candle, breaking its small counted squares.\n\nWet footsteps crossed the ceiling. One drop fell into the basin.\n\nI looked up. No stain. No crack.\n\nOn the wall, Iris had two shadows.\n\nOne of them lifted a finger to its lips.", "before": "The kitchen was warm.\n\nAfter everything in the hall, that nearly broke me. A stove. A cloth over the bread. Someone's apron on a hook. I put the pumpkin on the table and held my hands towards the heat.\n\nApple cakes stood on a rack. Dust softened their edges, but heat was still rising from them.\n\n“I made those,” Iris said. “That evening. Sometimes I come in and think they must be ready to eat.”\n\nShe turned one over. It tapped the plate like a stone.\n\nBeside the stove was a beeswax candle, wrapped in a recipe. Lydia had written in the margin: One flame. One shadow. Count again before opening a door.\n\nI spread the paper beneath the lamp. The fold ran through a diagram of the candle, breaking its small counted squares.\n\nWet footsteps crossed the ceiling. One drop fell into the basin.\n\nI looked up. No stain. No crack.\n\nOn the wall, Iris had two shadows.\n\nOne of them lifted a finger to its lips.",
"after": "Along the restored pattern, a line of writing appeared. Keep a light at the empty place. Never let the guest sit there.\n\nIris lit the candle from the stove.\n\nHer second shadow stretched up the wall. Its head reached the ceiling, then passed through it. Something drew breath through clenched teeth.\n\n“The pumpkin keeps the road clear,” she said. “This light is for the rooms. Don't put it down in the dark.”\n\nA paper moth unfolded between the recipe pages. It circled the flame once and settled on the door latch. Part of a clock face was drawn across its wings.\n\nBeyond the door, Mother used the pet name she had called me as a child.\n\nNobody here could know it. I had never written it down.\n\nI brought the candle closer. The whisper stopped. A narrow strip of darkness withdrew from beneath the door.\n\nThe moth slipped through the latch. On its other wing, before it vanished, I read two words.\n\nClock room.", "after": "Along the restored pattern, a line of writing appeared. Keep a light at the empty place. Never let the guest sit there.\n\nIris lit the candle from the stove.\n\nHer second shadow stretched up the wall. Its head reached the ceiling, then passed through it. Something drew breath through clenched teeth.\n\n“The pumpkin keeps the road clear,” she said. “This light is for the rooms. Don't put it down in the dark.”\n\nA paper moth unfolded between the recipe pages. It circled the flame once and settled on the door latch. Part of a clock face was drawn across its wings.\n\nBeyond the door, Mother used the pet name she had called me as a child.\n\nNobody here could know it. I had never written it down.\n\nI brought the candle closer. The whisper stopped. A narrow strip of darkness withdrew from beneath the door.\n\nThe moth slipped through the latch. On its other wing, before it vanished, I read two words.\n\nClock room.",
"size": 7, "size": 7,
"clues": "40", "clues": "36,43,45",
"areas": "1,3,4,4;0,4,4,3;0,3,4,3", "areas": "1,3,4,4;0,4,4,3;0,3,4,3",
"illustrationAsset": "assets/stories/midnight-invitation/artwork/candle-v1.png", "illustrationAsset": "assets/stories/midnight-invitation/artwork/candle-v1.png",
"chapterId": "house", "chapterId": "house",
"chapter": "II · The guest beneath the floor", "chapter": "II · The guest beneath the floor",
"picture": "0001000001110000010000011100001110101101110111101" "picture": "0001000001110000010000011100001110101101110111101",
"mechanics": {
"omittedRow": 1,
"omittedColumn": 3,
"lantern": [
31,
6
]
}
}, },
{ {
"id": "moth", "id": "moth",
@@ -99,12 +107,21 @@
"before": "Twelve plates. A chipped cup. A silver handbell wrapped in a tea towel.\n\nIris set them on the kitchen table. The bell's clapper was trapped in folded paper. Twelve little crescents circled the rim, worn bright by someone's thumb.\n\nOn the paper, Lydia had written: Let the bell carry the true names. The mouth below cannot speak over it.\n\nI tried the bell. Nothing.\n\nIris went very still beside the window.\n\nAda stood outside, knocking without a sound. Her postmistress's coat was buttoned to the throat. She looked cold and desperately tired.\n\nI reached for the latch.\n\n“Ada is taller than that.”\n\nIris said it quietly. I looked again.\n\nThe coat touched the ground. The face barely cleared the sill.\n\nIt smiled. Something inside the smile smiled back.\n\nI withdrew my hand and bent over the folded pattern. The thing at the window tapped once for every square I touched.\n\nWhen I stopped, it kept tapping.", "before": "Twelve plates. A chipped cup. A silver handbell wrapped in a tea towel.\n\nIris set them on the kitchen table. The bell's clapper was trapped in folded paper. Twelve little crescents circled the rim, worn bright by someone's thumb.\n\nOn the paper, Lydia had written: Let the bell carry the true names. The mouth below cannot speak over it.\n\nI tried the bell. Nothing.\n\nIris went very still beside the window.\n\nAda stood outside, knocking without a sound. Her postmistress's coat was buttoned to the throat. She looked cold and desperately tired.\n\nI reached for the latch.\n\n“Ada is taller than that.”\n\nIris said it quietly. I looked again.\n\nThe coat touched the ground. The face barely cleared the sill.\n\nIt smiled. Something inside the smile smiled back.\n\nI withdrew my hand and bent over the folded pattern. The thing at the window tapped once for every square I touched.\n\nWhen I stopped, it kept tapping.",
"after": "The clapper dropped free.\n\nOne clear note filled the kitchen.\n\nThe face at the window flattened against the glass, thin as wet paper. Then the pane was empty.\n\nFrom the hall came a woman's voice. Lydia Vale. Just her name. Nothing asked. Nothing offered.\n\nIris held the table so tightly that her fingers whitened.\n\n“She can hear us.”\n\nFor the first time, she sounded like someone with somewhere to go.\n\nInside the tea towel, Lydia had left the order of things. Open the orchard way. Set the moon in motion. Read the twelve names. Return the invitation before the final stroke.\n\nA drawing connected the clock's moon to the folded chair by a wire. Once the moon was restored, opening the chair would start the chime. We would have to be ready.\n\nI reached into my satchel.\n\nThe envelope was open. Inside it, the invitation had been torn in half, straight through the instruction we needed.\n\nAlong the tear were small, wet dents.\n\nTeeth marks.\n\nIris fetched her mother's sewing tin. I sat at the kitchen table, well away from the other room, and tried to fit the pieces together.", "after": "The clapper dropped free.\n\nOne clear note filled the kitchen.\n\nThe face at the window flattened against the glass, thin as wet paper. Then the pane was empty.\n\nFrom the hall came a woman's voice. Lydia Vale. Just her name. Nothing asked. Nothing offered.\n\nIris held the table so tightly that her fingers whitened.\n\n“She can hear us.”\n\nFor the first time, she sounded like someone with somewhere to go.\n\nInside the tea towel, Lydia had left the order of things. Open the orchard way. Set the moon in motion. Read the twelve names. Return the invitation before the final stroke.\n\nA drawing connected the clock's moon to the folded chair by a wire. Once the moon was restored, opening the chair would start the chime. We would have to be ready.\n\nI reached into my satchel.\n\nThe envelope was open. Inside it, the invitation had been torn in half, straight through the instruction we needed.\n\nAlong the tear were small, wet dents.\n\nTeeth marks.\n\nIris fetched her mother's sewing tin. I sat at the kitchen table, well away from the other room, and tried to fit the pieces together.",
"size": 7, "size": 7,
"clues": "", "clues": "3,26,41,45",
"areas": "2,0,4,4;1,0,3,3;2,0,4,3", "areas": "2,0,4,4;1,0,3,3;2,0,4,3",
"illustrationAsset": "assets/stories/midnight-invitation/artwork/bell-v1.png", "illustrationAsset": "assets/stories/midnight-invitation/artwork/bell-v1.png",
"chapterId": "house", "chapterId": "house",
"chapter": "II · The guest beneath the floor", "chapter": "II · The guest beneath the floor",
"picture": "0001000001110000101000110110011111011111110001000" "picture": "0001000001110000101000110110011111011111110001000",
"mechanics": {
"omittedRow": 5,
"omittedColumn": 3,
"trail": [
33,
40,
47
]
}
}, },
{ {
"id": "needle", "id": "needle",
@@ -129,12 +146,20 @@
"before": "We carried the candle, the bell and Lydia's page into the parlour. Iris laid the names on a side table, then lifted the linen from one corner of the mirror.\n\nMy reflection was already looking at me.\n\nI had not raised my head. I was watching the cloth. I remember its frayed hem, one loose blue thread.\n\nBut I could feel him watching.\n\nPieces were missing from the wooden frame. At each gap, his movement came a little before mine. The invitation's backwards letters scattered across the clouded glass.\n\nIris set the candle on the shelf.\n\n“Mend the border. Whatever he does, keep working.”\n\nHe took off his mask.\n\nThere was a hollow underneath, pale and unfinished. A crease began to open where his mouth should be.\n\nI kept my mask on. I worked from the squares that were still in place.\n\nHe leaned close to the glass and pointed behind me, towards the dining room.\n\nTowards my chair.", "before": "We carried the candle, the bell and Lydia's page into the parlour. Iris laid the names on a side table, then lifted the linen from one corner of the mirror.\n\nMy reflection was already looking at me.\n\nI had not raised my head. I was watching the cloth. I remember its frayed hem, one loose blue thread.\n\nBut I could feel him watching.\n\nPieces were missing from the wooden frame. At each gap, his movement came a little before mine. The invitation's backwards letters scattered across the clouded glass.\n\nIris set the candle on the shelf.\n\n“Mend the border. Whatever he does, keep working.”\n\nHe took off his mask.\n\nThere was a hollow underneath, pale and unfinished. A crease began to open where his mouth should be.\n\nI kept my mask on. I worked from the squares that were still in place.\n\nHe leaned close to the glass and pointed behind me, towards the dining room.\n\nTowards my chair.",
"after": "The last piece fitted. He stopped moving.\n\nIn the clear glass, I could read the address at last.\n\nTo the bearer. The thirteenth place is yours. Deliver yourself by hand.\n\nAll that way. All those doors. I had been carrying myself to the house.\n\nThen the stitches sharpened in the mirror. Lydia's small, firm handwriting ran between them.\n\nReturn to sender. Open the way for the twelve. Burn this at the empty place as the clock strikes. Leave the thirteenth chair unoccupied. Refuse the last place, and the house must release every name it holds.\n\nIris read it again, her lips moving.\n\n“The invitation goes back. You don't go with it.”\n\nShe looked up at me.\n\n“We can both leave.”\n\nThe man in the glass opened his new mouth. A knock sounded beneath the floor. Slow. Patient.\n\nI found an inkwell on the side table. With the raven's feather, I wrote Return to sender across the envelope. My hand shook. The words were legible.\n\nThe house made a sound I had not heard from it before.\n\nPain.\n\nI put the invitation back inside and left the flap open. Iris gathered the bell and the names. First the orchard. Then the clock.\n\nWe had the order. Now we had to do it.", "after": "The last piece fitted. He stopped moving.\n\nIn the clear glass, I could read the address at last.\n\nTo the bearer. The thirteenth place is yours. Deliver yourself by hand.\n\nAll that way. All those doors. I had been carrying myself to the house.\n\nThen the stitches sharpened in the mirror. Lydia's small, firm handwriting ran between them.\n\nReturn to sender. Open the way for the twelve. Burn this at the empty place as the clock strikes. Leave the thirteenth chair unoccupied. Refuse the last place, and the house must release every name it holds.\n\nIris read it again, her lips moving.\n\n“The invitation goes back. You don't go with it.”\n\nShe looked up at me.\n\n“We can both leave.”\n\nThe man in the glass opened his new mouth. A knock sounded beneath the floor. Slow. Patient.\n\nI found an inkwell on the side table. With the raven's feather, I wrote Return to sender across the envelope. My hand shook. The words were legible.\n\nThe house made a sound I had not heard from it before.\n\nPain.\n\nI put the invitation back inside and left the flap open. Iris gathered the bell and the names. First the orchard. Then the clock.\n\nWe had the order. Now we had to do it.",
"size": 7, "size": 7,
"clues": "18,25,27,28", "clues": "18,25,28,34,35",
"areas": "2,2,4,4;1,2,4,3;0,4,3,3", "areas": "2,2,4,4;1,2,4,3;0,4,3,3",
"illustrationAsset": "assets/stories/midnight-invitation/artwork/mirror-v1.png", "illustrationAsset": "assets/stories/midnight-invitation/artwork/mirror-v1.png",
"chapterId": "welcome", "chapterId": "welcome",
"chapter": "III · Return to sender", "chapter": "III · Return to sender",
"picture": "0011100011011011000111100011011011000111000011100" "picture": "0011100011011011000111100011011011000111000011100",
"mechanics": {
"omittedRow": 5,
"omittedColumn": 0,
"lantern": [
45,
36
]
}
}, },
{ {
"id": "gate", "id": "gate",
@@ -159,12 +184,21 @@
"before": "The clock room smelled of cold metal. I set the candle beside the mechanism and listened for Iris below.\n\nA door closed. Her footsteps moved away.\n\nBeneath the clock's hands, the painted moon had slipped from its track. Lydia had forced its crescent under a catch. Seventeen years of strain had nearly worn the brass through.\n\nI recognised the arrangement from her drawing. Put the moon back, and her stop would release. The wire to the folded chair would hold the last catch until we were ready.\n\nSomething leaned against the stair door below.\n\nA soft impact. Another. Then a steady thud, as though a shoulder were being driven into the wood.\n\nThe moth landed on my wrist. Its wings trembled at every blow.\n\nI thought of Iris turning that stone-hard cake over in her hands. Seventeen years, waiting for it to cool.\n\nI bent over the counted squares.\n\nOn the other side of the metal, another set of fingers touched mine.\n\nI did not take my hand away.", "before": "The clock room smelled of cold metal. I set the candle beside the mechanism and listened for Iris below.\n\nA door closed. Her footsteps moved away.\n\nBeneath the clock's hands, the painted moon had slipped from its track. Lydia had forced its crescent under a catch. Seventeen years of strain had nearly worn the brass through.\n\nI recognised the arrangement from her drawing. Put the moon back, and her stop would release. The wire to the folded chair would hold the last catch until we were ready.\n\nSomething leaned against the stair door below.\n\nA soft impact. Another. Then a steady thud, as though a shoulder were being driven into the wood.\n\nThe moth landed on my wrist. Its wings trembled at every blow.\n\nI thought of Iris turning that stone-hard cake over in her hands. Seventeen years, waiting for it to cool.\n\nI bent over the counted squares.\n\nOn the other side of the metal, another set of fingers touched mine.\n\nI did not take my hand away.",
"after": "The moon rose into place. A weight lifted inside the clock.\n\nThe whole house seemed to draw breath.\n\nIt did not strike.\n\nThe wire held. Beside the final catch, Lydia had scratched a little chair into the brass. Folded chair, silent clock. Open chair, midnight.\n\nI took the candle and went down.\n\nIris was waiting in the dining room. The bell was in her hand; the list lay open on the table. Twelve pale figures stood beside their places. Lydia was nearest the window.\n\nThe thirteenth chair remained folded. Its cushion had caught in the frame. Red and gold squares showed between the hinges.\n\nOn the wall, my shadow sat down.\n\nI stayed standing.\n\nIris looked at me, then at the shadow. Neither of us spoke. The white line round her wrist was darkening again.\n\nI carried the candle to the empty place.", "after": "The moon rose into place. A weight lifted inside the clock.\n\nThe whole house seemed to draw breath.\n\nIt did not strike.\n\nThe wire held. Beside the final catch, Lydia had scratched a little chair into the brass. Folded chair, silent clock. Open chair, midnight.\n\nI took the candle and went down.\n\nIris was waiting in the dining room. The bell was in her hand; the list lay open on the table. Twelve pale figures stood beside their places. Lydia was nearest the window.\n\nThe thirteenth chair remained folded. Its cushion had caught in the frame. Red and gold squares showed between the hinges.\n\nOn the wall, my shadow sat down.\n\nI stayed standing.\n\nIris looked at me, then at the shadow. Neither of us spoke. The white line round her wrist was darkening again.\n\nI carried the candle to the empty place.",
"size": 7, "size": 7,
"clues": "8,21,36", "clues": "0,9,16,17,24,31,42",
"areas": "1,1,4,3;2,0,4,3;0,1,4,3", "areas": "1,1,4,3;2,0,4,3;0,1,4,3",
"illustrationAsset": "assets/stories/midnight-invitation/artwork/moon-v1.png", "illustrationAsset": "assets/stories/midnight-invitation/artwork/moon-v1.png",
"chapterId": "welcome", "chapterId": "welcome",
"chapter": "III · Return to sender", "chapter": "III · Return to sender",
"picture": "0001110001100001100001100000011000000110000001110" "picture": "0001110001100001100001100000011000000110000001110",
"mechanics": {
"omittedRow": 2,
"omittedColumn": 0,
"trail": [
36,
37,
38
]
}
}, },
{ {
"id": "chair", "id": "chair",
+13 -1
View File
@@ -21,13 +21,15 @@ class CampaignLevel {
illustrationAsset = data['illustrationAsset'] as String?, illustrationAsset = data['illustrationAsset'] as String?,
picture = (data['picture'] as String).split('').map(int.parse).toList(), picture = (data['picture'] as String).split('').map(int.parse).toList(),
clues = data['clues'], clues = data['clues'],
areas = data['areas']; areas = data['areas'],
mechanics = Map<String, dynamic>.from(data['mechanics'] as Map? ?? {});
final String id, chapterId; final String id, chapterId;
final int size; final int size;
final String chapter, title, object, before, after, clues, areas; final String chapter, title, object, before, after, clues, areas;
final String beforeContinuation, afterContinuation; final String beforeContinuation, afterContinuation;
final String? illustrationAsset; final String? illustrationAsset;
final List<int> picture; final List<int> picture;
final Map<String, dynamic> mechanics;
Puzzle puzzle() { Puzzle puzzle() {
final p = Puzzle(size, picture); final p = Puzzle(size, picture);
if (clues.isNotEmpty) { if (clues.isNotEmpty) {
@@ -51,6 +53,16 @@ class CampaignLevel {
); );
} }
} }
if (mechanics.isNotEmpty) {
p.omittedRow = mechanics['omittedRow'] as int;
p.omittedColumn = mechanics['omittedColumn'] as int;
if (mechanics['lantern'] case final List pair) {
p.lanternPairs.add(LanternPair(pair[0] as int, pair[1] as int));
}
if (mechanics['trail'] case final List trail) {
p.footprintTrails.add(trail.cast<int>());
}
}
return p; return p;
} }
} }
+133
View File
@@ -0,0 +1,133 @@
// Generated by tool/tune_postcard_puzzles.dart. Null keeps the original givens.
const postcardTunedGivens = <List<int>?>[
null,
null,
null,
null,
null,
null,
null,
null,
[14, 15, 16, 48],
[4, 7, 12, 13, 17],
null,
[1, 7, 10, 11, 21, 23, 24, 40, 48],
[6, 7, 17, 22, 27],
[0, 20, 21, 22, 29, 39, 42],
[7, 16, 19, 25, 32, 41, 46],
[15, 17, 34, 38],
[7, 11, 24, 26, 29, 31, 35],
[7, 9, 14, 22, 47],
[3, 13, 33, 39, 44, 45],
[36, 38, 47],
[2, 6, 12, 16, 17, 25, 33],
[4, 9, 11, 14, 20, 24, 31, 32, 36],
[7, 18, 29, 31],
[16, 19, 22, 32, 40],
[7, 8, 12, 16, 33, 39, 44, 46],
[2, 28, 33, 35, 44, 47],
[5, 9, 14, 25, 37, 39],
[7, 14, 17, 36, 43, 44, 45],
[0, 4, 13, 22, 27, 30, 45, 48],
[9, 14, 15, 22, 25, 29, 32, 48],
[15, 26, 29, 30, 34, 42],
[7, 13, 16, 17, 24, 27, 30, 43, 47],
[8, 24, 33, 45],
[10, 25, 26, 31],
[9, 15, 20, 30, 41, 42, 45, 48],
[1, 10, 12, 14, 19, 22, 27, 40],
[0, 20, 31, 34, 37, 40, 45, 48],
[5, 9, 11, 14, 22, 31, 46],
[9, 12, 15, 21, 29, 38, 44],
[15, 18, 19, 21, 35],
[7, 9, 15, 18, 20],
[5, 13, 16, 26, 30, 31, 33, 46],
];
const postcardTunedTrails = <List<int>?>[
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
[18, 25, 32],
null,
null,
null,
null,
null,
[16, 17, 18],
null,
null,
[11, 18, 25],
null,
null,
[4, 11, 18],
null,
null,
null,
null,
null,
null,
null,
null,
[25, 32, 39],
null,
];
const postcardTunedLanterns = <List<int>?>[
null,
null,
null,
null,
null,
null,
null,
null,
[6, 37],
null,
null,
[20, 29],
null,
null,
[26, 42],
null,
null,
[16, 43],
null,
null,
[19, 36],
null,
null,
[2, 8],
null,
null,
[19, 34],
null,
null,
[2, 10],
null,
null,
[9, 26],
null,
null,
[3, 16],
null,
null,
[24, 46],
null,
null,
[25, 29],
];
+24 -1
View File
@@ -1,4 +1,5 @@
import 'postcard_patterns.dart'; import 'postcard_patterns.dart';
import 'postcard_tuned_givens.dart';
import 'puzzle.dart'; import 'puzzle.dart';
/// A separate collection; it never changes a book's saved position. /// A separate collection; it never changes a book's saved position.
@@ -10,7 +11,7 @@ class IslandPostcard {
String puzzleKey(int slot) => 'postcard_v2_${id}_$slot'; String puzzleKey(int slot) => 'postcard_v2_${id}_$slot';
String legacyPuzzleKey(int slot) => 'postcard_v1_${id}_$slot'; String legacyPuzzleKey(int slot) => 'postcard_v1_${id}_$slot';
Puzzle puzzle(int slot) { Puzzle puzzle(int slot, {bool useTunedGivens = true}) {
RangeError.checkValidIndex(slot, const [0, 1, 2]); RangeError.checkValidIndex(slot, const [0, 1, 2]);
final index = islandPostcards.indexOf(this); final index = islandPostcards.indexOf(this);
final (picture, clues) = postcardPatterns[index * puzzlesPerOuting + slot]; final (picture, clues) = postcardPatterns[index * puzzlesPerOuting + slot];
@@ -55,6 +56,10 @@ class IslandPostcard {
for (var row = 1; row < 7; row++) { for (var row = 1; row < 7; row++) {
if (board.rows[row] == board.rows[row - 1] + 1) { if (board.rows[row] == board.rows[row - 1] + 1) {
board.hiddenRow = row; board.hiddenRow = row;
board.hiddenColumn = index % 7;
board.hiddenTotalCells.addAll([
for (var c = 0; c < 3; c++) ((row + 3) % 7) * 7 + c * 2,
]);
break; break;
} }
} }
@@ -85,6 +90,24 @@ class IslandPostcard {
} }
} }
} }
final tuned = postcardTunedGivens[index * puzzlesPerOuting + slot];
final tunedPair = postcardTunedLanterns[index * puzzlesPerOuting + slot];
if (useTunedGivens && tunedPair != null) {
board.lanternPairs
..clear()
..add(LanternPair(tunedPair[0], tunedPair[1]));
}
final tunedTrail = postcardTunedTrails[index * puzzlesPerOuting + slot];
if (useTunedGivens && tunedTrail != null) {
board.footprintTrails
..clear()
..add(tunedTrail);
}
if (useTunedGivens && tuned != null) {
for (var cell = 0; cell < board.given.length; cell++) {
board.given[cell] = tuned.contains(cell);
}
}
return board; return board;
} }
} }
+24 -10
View File
@@ -270,6 +270,16 @@ class Puzzle {
final List<LanternPair> mirrorPairs = []; final List<LanternPair> mirrorPairs = [];
final List<List<int>> footprintTrails = []; final List<List<int>> footprintTrails = [];
int? hiddenRow; int? hiddenRow;
int? hiddenColumn;
int? omittedRow, omittedColumn;
final List<int> hiddenTotalCells = [];
List<int> get hiddenClueCells => [
if (hiddenRow != null)
for (var c = 0; c < size; c++) hiddenRow! * size + c,
...hiddenTotalCells,
];
int get hiddenClueTotal =>
hiddenClueCells.fold(0, (sum, cell) => sum + solution[cell]);
List<int> get rows => List.generate( List<int> get rows => List.generate(
size, size,
(r) => List.generate( (r) => List.generate(
@@ -289,6 +299,8 @@ class Puzzle {
(i) => r.contains(i, size) ? solution[i] : 0, (i) => r.contains(i, size) ? solution[i] : 0,
).reduce((a, b) => a + b); ).reduce((a, b) => a + b);
List<Constraint> get constraints => [ List<Constraint> get constraints => [
if (hiddenRow != null)
Constraint(hiddenClueCells, hiddenClueTotal, 'Combined hidden total'),
for (final trail in footprintTrails) ...[ for (final trail in footprintTrails) ...[
Constraint([trail[1]], 1, 'Footprint trail centre'), Constraint([trail[1]], 1, 'Footprint trail centre'),
Constraint([trail[0], trail[2]], 1, 'Footprint trail ends'), Constraint([trail[0], trail[2]], 1, 'Footprint trail ends'),
@@ -298,16 +310,18 @@ class Puzzle {
for (final pair in lanternPairs) for (final pair in lanternPairs)
Constraint([pair.first, pair.second], 1, 'Lantern pair'), Constraint([pair.first, pair.second], 1, 'Lantern pair'),
for (var l = 0; l < size; l++) ...[ for (var l = 0; l < size; l++) ...[
Constraint( if (l != hiddenRow && l != omittedRow)
List.generate(size, (p) => l * size + p), Constraint(
rows[l], List.generate(size, (p) => l * size + p),
'Row ${l + 1}', rows[l],
), 'Row ${l + 1}',
Constraint( ),
List.generate(size, (p) => p * size + l), if (l != hiddenColumn && l != omittedColumn)
cols[l], Constraint(
'Column ${l + 1}', List.generate(size, (p) => p * size + l),
), cols[l],
'Column ${l + 1}',
),
], ],
for (final r in regions) for (final r in regions)
Constraint( Constraint(
+7 -1
View File
@@ -1533,6 +1533,12 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
} }
List<Widget> puzzleNotes() => [ List<Widget> puzzleNotes() => [
if (g.puzzle?.omittedRow != null)
writing(
'Two totals have faded. Use the marked cells and area clues to recover the pattern.',
size: 19,
color: regionInk,
),
if (g.puzzle?.footprintTrails.isNotEmpty ?? false) if (g.puzzle?.footprintTrails.isNotEmpty ?? false)
writing( writing(
'Footprints: exactly two marked cells are lit, and they touch.', 'Footprints: exactly two marked cells are lit, and they touch.',
@@ -1547,7 +1553,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
), ),
if (g.puzzle?.hiddenRow case final row?) if (g.puzzle?.hiddenRow case final row?)
writing( writing(
'Row ${row + 1} has one more light than row $row.', 'Row ${row + 1} and the diamond-marked cells together contain ${g.puzzle!.hiddenClueTotal} lights. Recover both missing totals.',
size: 19, size: 19,
color: regionInk, color: regionInk,
), ),
+78 -11
View File
@@ -107,11 +107,16 @@ class Board extends StatelessWidget {
SizedBox(width: u, height: u), SizedBox(width: u, height: u),
for (var col = 0; col < n; col++) for (var col = 0; col < n; col++)
clue( clue(
'${puzzle.cols[col]}', puzzle.hiddenColumn == col ||
complete( puzzle.omittedColumn == col
List.generate(n, (i) => i * n + col), ? '?'
puzzle.cols[col], : '${puzzle.cols[col]}',
), puzzle.hiddenColumn != col &&
puzzle.omittedColumn != col &&
complete(
List.generate(n, (i) => i * n + col),
puzzle.cols[col],
),
), ),
], ],
), ),
@@ -120,10 +125,12 @@ class Board extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
clue( clue(
puzzle.hiddenRow == row puzzle.hiddenRow == row ||
puzzle.omittedRow == row
? '?' ? '?'
: '${puzzle.rows[row]}', : '${puzzle.rows[row]}',
puzzle.hiddenRow != row && puzzle.hiddenRow != row &&
puzzle.omittedRow != row &&
complete( complete(
List.generate(n, (i) => row * n + i), List.generate(n, (i) => row * n + i),
puzzle.rows[row], puzzle.rows[row],
@@ -238,6 +245,25 @@ class Board extends StatelessWidget {
), ),
), ),
), ),
if (puzzle
.hiddenTotalCells
.contains(i))
Positioned(
left: 1,
top: 1,
child: Container(
key: ValueKey(
'diamond-$i',
),
color: cream,
child: Icon(
Icons
.diamond_outlined,
size: u * .31,
color: regionInk,
),
),
),
if (mirrored) if (mirrored)
Positioned( Positioned(
left: 1, left: 1,
@@ -282,11 +308,13 @@ class Board extends StatelessWidget {
const EdgeInsets.all( const EdgeInsets.all(
1, 1,
), ),
child: Icon( child: SizedBox.square(
Icons dimension:
.directions_walk, u * .31,
size: u * .31, child: CustomPaint(
color: regionInk, painter:
FootprintMark(),
),
), ),
), ),
), ),
@@ -350,6 +378,45 @@ class Board extends StatelessWidget {
); );
} }
/// A tiny shoe print, used only as a marker inside a puzzle cell.
class FootprintMark extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = regionInk;
canvas.save();
canvas.translate(size.width * .5, size.height * .5);
canvas.rotate(-.35);
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(
-size.width * .25,
-size.height * .46,
size.width * .5,
size.height * .55,
),
Radius.circular(size.width * .22),
),
paint,
);
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(
-size.width * .2,
size.height * .16,
size.width * .4,
size.height * .27,
),
Radius.circular(size.width * .1),
),
paint,
);
canvas.restore();
}
@override
bool shouldRepaint(covariant FootprintMark oldDelegate) => false;
}
/// Deterministic pencil strokes stay put when the player revisits a cell. /// Deterministic pencil strokes stay put when the player revisits a cell.
/// Both marks use paths, so their appearance never depends on a fallback font. /// Both marks use paths, so their appearance never depends on a fallback font.
class PencilMark extends CustomPainter { class PencilMark extends CustomPainter {
+82 -1
View File
@@ -5,6 +5,7 @@ import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart'; import 'package:lumen/domain/game.dart';
import 'package:lumen/domain/library.dart'; import 'package:lumen/domain/library.dart';
import 'package:lumen/domain/postcards.dart'; import 'package:lumen/domain/postcards.dart';
import 'package:lumen/domain/postcard_tuned_givens.dart';
import 'package:lumen/domain/puzzle.dart'; import 'package:lumen/domain/puzzle.dart';
import 'package:lumen/services/ad_pacing.dart'; import 'package:lumen/services/ad_pacing.dart';
import 'package:lumen/services/play_metrics.dart'; import 'package:lumen/services/play_metrics.dart';
@@ -21,6 +22,74 @@ void solve(Game game) {
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
test('advanced story puzzles need their special rule and preserve their pictures', () async {
final library = await StoryLibrary.load();
var count = 0;
for (final definition in library.stories) {
final book = await library.open(definition.id);
for (final level in book.levels) {
final p = level.puzzle();
if (level.mechanics.isEmpty) continue;
count++;
final without = p.constraints
.where(
(c) =>
c.name != 'Lantern pair' &&
!c.name.startsWith('Footprint trail'),
)
.toList();
expect(p.solution, level.picture);
expect(p.countSolutions(), 1, reason: level.id);
expect(
LogicSolver(49, p.constraints).analyze(p.initial).solved,
isTrue,
reason: level.id,
);
expect(
LogicSolver(49, without).countSolutions(p.initial),
greaterThan(1),
reason: level.id,
);
}
}
expect(count, 8);
});
test('tuned boards require their special rule for a unique solution', () {
var count = 0;
for (var i = 0; i < islandPostcards.length; i++) {
for (var slot = 0; slot < 3; slot++) {
final p = islandPostcards[i].puzzle(slot);
final hasSpecial =
p.lanternPairs.isNotEmpty ||
p.mirrorPairs.isNotEmpty ||
p.footprintTrails.isNotEmpty ||
p.hiddenRow != null;
if (!hasSpecial) continue;
expect(postcardTunedGivens[i * 3 + slot], isNotNull);
count++;
final without = p.constraints
.where(
(c) =>
!(p.lanternPairs.isNotEmpty && c.name == 'Lantern pair') &&
!(p.mirrorPairs.isNotEmpty && c.equal) &&
!(p.footprintTrails.isNotEmpty &&
c.name.startsWith('Footprint trail')) &&
!(p.hiddenRow != null && c.name == 'Combined hidden total'),
)
.toList();
expect(
LogicSolver(49, without).countSolutions(p.initial),
greaterThan(1),
);
expect(p.countSolutions(), 1);
expect(
LogicSolver(49, p.constraints).analyze(p.initial).solved,
isTrue,
);
}
}
expect(count, 33);
});
test('hidden totals and mirrored pairs agree with the saved solutions', () { test('hidden totals and mirrored pairs agree with the saved solutions', () {
var hidden = 0, mirrors = 0, trails = 0; var hidden = 0, mirrors = 0, trails = 0;
for (final card in islandPostcards) { for (final card in islandPostcards) {
@@ -35,7 +104,19 @@ void main() {
final row = p.hiddenRow; final row = p.hiddenRow;
if (row != null) { if (row != null) {
hidden++; hidden++;
expect(p.rows[row], p.rows[row - 1] + 1); expect(p.hiddenColumn, isNotNull);
expect(p.constraints.any((c) => c.name == 'Row ${row + 1}'), isFalse);
expect(
p.constraints.any((c) => c.name == 'Column ${p.hiddenColumn! + 1}'),
isFalse,
);
expect(p.hiddenTotalCells.length, 3);
expect(
p.hiddenClueTotal,
p.hiddenClueCells
.map((cell) => p.solution[cell])
.reduce((a, b) => a + b),
);
} }
for (final pair in p.mirrorPairs) { for (final pair in p.mirrorPairs) {
mirrors++; mirrors++;
+140
View File
@@ -0,0 +1,140 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'package:lumen/domain/puzzle.dart';
import 'package:lumen/domain/thinking.dart';
void main() {
for (final path in [
'assets/campaign.json',
'assets/stories/midnight-invitation/campaign.json',
]) {
final data =
jsonDecode(File(path).readAsStringSync()) as Map<String, dynamic>;
final levels = data['levels'] as List;
for (final index in [4, 6, 8, 10]) {
final level = levels[index] as Map<String, dynamic>;
final solution = (level['picture'] as String)
.split('')
.map(int.parse)
.toList();
final rng = Random(8721 + index);
final trails = <List<int>>[];
for (var a = 0; a < 49; a++) {
for (final step in [1, 7]) {
final cells = [a, a + step, a + 2 * step];
if (cells.last >= 49 || (step == 1 && a ~/ 7 != cells.last ~/ 7)) {
continue;
}
if (solution[cells[1]] == 1 &&
solution[cells[0]] + solution[cells[2]] == 1) {
trails.add(cells);
}
}
}
Map<String, dynamic>? chosen;
List<int>? givens;
for (var attempt = 0; attempt < 600; attempt++) {
final p = Puzzle(7, solution);
for (final area
in (level['areas'] as String)
.split(';')
.where((a) => a.isNotEmpty)) {
final v = area.split(',').map(int.parse).toList();
p.regions.add(
Region(
String.fromCharCode(65 + p.regions.length),
v[0],
v[1],
v[2],
v[3],
),
);
}
p.omittedRow = rng.nextInt(7);
p.omittedColumn = rng.nextInt(7);
final mechanics = <String, dynamic>{
'omittedRow': p.omittedRow,
'omittedColumn': p.omittedColumn,
};
final marked = <int>{};
if (index == 6 || index == 10) {
final trail = trails[rng.nextInt(trails.length)];
p.footprintTrails.add(trail);
marked.addAll(trail);
mechanics['trail'] = trail;
} else {
final a = rng.nextInt(49);
final options = [
for (var b = 0; b < 49; b++)
if (solution[a] != solution[b] &&
a ~/ 7 != b ~/ 7 &&
a % 7 != b % 7)
b,
];
if (options.isEmpty) continue;
final b = options[rng.nextInt(options.length)];
p.lanternPairs.add(LanternPair(a, b));
marked.addAll([a, b]);
mechanics['lantern'] = [a, b];
}
for (var j = 0; j < 49; j++) {
p.given[j] = !marked.contains(j);
}
final full = p.constraints;
final order = [
for (var j = 0; j < 49; j++)
if (p.given[j]) j,
]..shuffle(rng);
for (final cell in order) {
p.given[cell] = false;
if (!LogicSolver(49, full).analyze(p.initial).solved ||
p.countSolutions() != 1) {
p.given[cell] = true;
}
}
final without = full
.where(
(c) =>
c.name != 'Lantern pair' &&
!c.name.startsWith('Footprint trail'),
)
.toList();
final logic = LogicSolver(49, full).analyze(p.initial);
final thinking = ThinkingAnalyzer(
49,
full,
).analyze(p.initial, maxLookahead: 0);
final start = LogicSolver(49, full).analyze(p.initial, useAreas: false);
final paced = path == 'assets/campaign.json'
? logic.areaDeductions <= (index < 8 ? 5 : 6) &&
start.cells.where((v) => v >= 0).length -
p.given.where((v) => v).length >=
7
: thinking.rounds.length >= 4 &&
thinking.rounds.length <= 8 &&
thinking.comparisonSteps >= 2;
if (paced &&
p.countSolutions() == 1 &&
LogicSolver(49, full).analyze(p.initial).solved &&
!LogicSolver(49, full).analyze(p.initial, useAreas: false).solved &&
LogicSolver(49, without).countSolutions(p.initial) > 1) {
chosen = mechanics;
givens = [
for (var j = 0; j < 49; j++)
if (p.given[j]) j,
];
break;
}
}
if (chosen == null) throw StateError('No authored board: $path $index');
level['mechanics'] = chosen;
level['clues'] = givens!.join(',');
stderr.writeln('$path ${level['id']}: ${givens.length} givens, $chosen');
}
File(path).writeAsStringSync(
'${const JsonEncoder.withIndent(' ').convert(data)}\n',
);
}
}
+152
View File
@@ -0,0 +1,152 @@
import 'dart:io';
import 'dart:math';
import 'package:lumen/domain/postcards.dart';
import 'package:lumen/domain/puzzle.dart';
void main() {
final out = <String>[
'// Generated by tool/tune_postcard_puzzles.dart. Null keeps the original givens.',
'const postcardTunedGivens = <List<int>?>[',
];
final trailsOut = <String>[];
final pairsOut = <String>[];
for (var i = 0; i < islandPostcards.length; i++) {
for (var slot = 0; slot < 3; slot++) {
final p = islandPostcards[i].puzzle(slot, useTunedGivens: false);
bool special(Constraint c) =>
(p.lanternPairs.isNotEmpty && c.name == 'Lantern pair') ||
(p.mirrorPairs.isNotEmpty && c.equal) ||
(p.footprintTrails.isNotEmpty &&
c.name.startsWith('Footprint trail')) ||
(p.hiddenRow != null && c.name == 'Combined hidden total');
final full = p.constraints,
without = full.where((c) => !special(c)).toList();
if (full.length == without.length) {
out.add(' null,');
trailsOut.add(' null,');
pairsOut.add(' null,');
continue;
}
final marked = <int>{
for (final pair in [...p.lanternPairs, ...p.mirrorPairs]) ...[
pair.first,
pair.second,
],
for (final trail in p.footprintTrails) ...trail,
...p.hiddenTotalCells,
};
final initial = [
for (var j = 0; j < 49; j++)
if (!marked.contains(j)) j,
];
List<int>? best;
List<int>? bestTrail;
List<int>? bestPair;
final pairCandidates = <LanternPair>[];
if (p.lanternPairs.isNotEmpty) {
for (var a = 0; a < 49; a++) {
for (var b = a + 1; b < 49; b++) {
if (p.solution[a] != p.solution[b] &&
a ~/ 7 != b ~/ 7 &&
a % 7 != b % 7) {
pairCandidates.add(LanternPair(a, b));
}
}
}
pairCandidates.shuffle(Random(i * 79 + slot));
}
final trailCandidates = <List<int>>[];
if (p.footprintTrails.isNotEmpty) {
for (var a = 0; a < 49; a++) {
for (final step in [1, 7]) {
final cells = [a, a + step, a + 2 * step];
if (cells.last >= 49 || (step == 1 && a ~/ 7 != cells.last ~/ 7)) {
continue;
}
if (p.solution[cells[1]] == 1 &&
p.solution[cells[0]] + p.solution[cells[2]] == 1) {
trailCandidates.add(cells);
}
}
}
}
for (var attempt = 0; attempt < 200; attempt++) {
if (pairCandidates.isNotEmpty) {
p.lanternPairs
..clear()
..add(pairCandidates[attempt % pairCandidates.length]);
full
..clear()
..addAll(p.constraints);
without
..clear()
..addAll(full.where((c) => !special(c)));
}
if (trailCandidates.isNotEmpty) {
p.footprintTrails
..clear()
..add(trailCandidates[attempt % trailCandidates.length]);
full.clear();
full.addAll(p.constraints);
without
..clear()
..addAll(full.where((c) => !special(c)));
}
final order = List<int>.of(initial)
..shuffle(Random(39139 + i * 423 + slot * 11 + attempt));
final given = List.generate(
49,
(j) =>
initial.contains(j) &&
!p.footprintTrails.any((t) => t.contains(j)) &&
!p.lanternPairs.any((pair) => pair.contains(j)),
);
for (final j in order) {
given[j] = false;
final state = List.generate(49, (k) => given[k] ? p.solution[k] : -1);
if (!LogicSolver(49, full).analyze(state).solved ||
LogicSolver(49, full).countSolutions(state) != 1) {
given[j] = true;
}
}
final state = List.generate(49, (k) => given[k] ? p.solution[k] : -1);
if (LogicSolver(49, without).countSolutions(state) > 1) {
final found = [
for (var j = 0; j < 49; j++)
if (given[j]) j,
];
if (best == null || found.length < best.length) {
best = found;
if (p.footprintTrails.isNotEmpty) {
bestTrail = List.of(p.footprintTrails.single);
}
if (p.lanternPairs.isNotEmpty) {
bestPair = [
p.lanternPairs.single.first,
p.lanternPairs.single.second,
];
}
}
if (attempt >= 10) break;
}
}
stderr.writeln(
'${i + 1}/$slot ${best == null ? 'NO SOLUTION' : '${initial.length} -> ${best.length}'}',
);
if (best == null) throw StateError('Could not author $i/$slot');
out.add(' $best,');
trailsOut.add(bestTrail == null ? ' null,' : ' $bestTrail,');
pairsOut.add(bestPair == null ? ' null,' : ' $bestPair,');
}
}
out.add('];');
out.add(
'const postcardTunedTrails = <List<int>?>[\n${trailsOut.join('\n')}\n];',
);
out.add(
'const postcardTunedLanterns = <List<int>?>[\n${pairsOut.join('\n')}\n];',
);
File('lib/domain/postcard_tuned_givens.dart')
.writeAsStringSync('${out.join('\n')}\n');
}