DEV Community

Harry
Harry

Posted on

Dawn Cipher — A June Solstice Tribute to Alan Turing Featuring Gemini AI

June Solstice Game Jam Submission

This is a submission for the June Solstice Game Jam


Dawn Cipher title screen

What I Built

Dawn Cipher is a browser-based puzzle game where you race against the solstice sun to crack four ciphers — and in doing so, uncover a story hidden in plain sight.

It is June 21st. The longest day of the year. A daylight meter at the top of the screen ticks down in real time. Four ciphers stand between you and the truth. Each solved puzzle unlocks a fragment of a narrative that weaves together Alan Turing, Pride Month, Juneteenth, and the meaning of the solstice itself.

The game is a single HTML file — no installs, no accounts, no dependencies. Open it in a browser and play. The final level can optionally connect to Gemini for live AI responses, but the game also includes a scripted fallback so judges can complete it without an API key.

The four ciphers:

  • Cipher I — The Shift: A Caesar cipher. Rotate a decoder wheel until a hidden message appears in real time. The answer is tied to something every June celebration shares.
  • Cipher II — The Signal: A Morse code puzzle. Decode dots and dashes to reveal a name that changed the world.
  • Cipher III — The Machine: Four 8-bit binary sequences. Convert them to ASCII text. The answer is what June's most important stories are ultimately about.
  • Cipher IV — The Question: A Turing Test that can run in scripted mode or with live Gemini API responses. Ask ENTITY-1 five questions, then decide: Human or AI? The answer — and the reflection that follows — is the heart of the game.

Between each level, a typewriter-animated narrative fragment reveals more of the story. After all four ciphers are solved, the screen fills with a pride-rainbow mosaic and the game's final message.


Video Demo

YouTube demo: https://youtu.be/2_9RDJpjVBI


Code

GitHub repo: harryPT4/dawn-cipher

The full game is a single dawn-cipher.html file (~60KB). No frameworks, no build step — pure HTML, CSS, and vanilla JavaScript with one optional external API call (Gemini).

To run it:

open dawn-cipher.html
Enter fullscreen mode Exit fullscreen mode

Or serve it locally:

python3 -m http.server 4173
Enter fullscreen mode Exit fullscreen mode

Then open:

http://127.0.0.1:4173/dawn-cipher.html
Enter fullscreen mode Exit fullscreen mode

Key technical pieces:

// Caesar cipher decoder — real-time as the player rotates the wheel
_decode(text, sh) {
  return text.split('').map(c => {
    if (!/[A-Z]/.test(c)) return c;
    return String.fromCharCode(((c.charCodeAt(0) - 65 - sh + 260) % 26) + 65);
  }).join('');
}

// Gemini API call — tries multiple models with graceful fallback
const models = ['gemini-1.5-flash', 'gemini-1.5-flash-latest', 'gemini-pro'];
for (const model of models) {
  const res = await fetch(
    `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${key}`,
    { method: 'POST', headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ system_instruction: { parts: [{ text: system }] }, contents: history })
    }
  );
  // ...
}
Enter fullscreen mode Exit fullscreen mode

How I Built It

The Core Idea

The brief said: build a game inspired by the solstice or any other June celebration. I wanted to do something that didn't just wear the theme as a costume — I wanted the theme to be the mechanic.

June is Pride. June is Juneteenth. June 21 is the solstice. And June 23 is the birthday of Alan Turing — the father of computer science, a gay man prosecuted by the state he helped save, and the inventor of the test that became Level 4 of this game.

The connection clicked: ciphers, light, and liberation are the same story told in different languages. A cipher hides the truth until you have the key. The longest day gives you the most light to work by. Turing's story, Juneteenth, Pride — all are about truths that were encoded, hidden, or delayed. All required someone to find the key.

That became the game.

Technical Approach

No dependencies. The entire game runs from one HTML file. This was a deliberate choice — I wanted it to be instantly playable anywhere, and I wanted the code to be readable without a build toolchain.

The daylight meter uses setInterval at 100ms ticks, draining a percentage from a CSS width value. It shifts colour from gold → orange → red as it depletes, and a low-light warning tone plays at 20% using the Web Audio API.

Sound effects are synthesised entirely via the Web Audio API — no audio files to load. Each event (shift click, correct answer, level complete) triggers a different oscillator pattern.

The Caesar cipher renders a live alphabet strip showing the current letter mapping as the player rotates the wheel. When the decoded text matches the target, a confirm button appears and a particle burst fires from the centre of the screen.

The Turing Test was the most interesting design challenge. Level 4 can use the Gemini API to power ENTITY-1 — a character who is instructed never to confirm whether they are human or AI. The full conversation history is passed with each message, so ENTITY-1 builds context across the five questions. If no API key is provided, a pool of 16 hand-written scripted responses covers the same territory thoughtfully, which keeps the full game playable for every judge.

The narrative fragments between levels use a typewriter animation to reveal prose connecting each cipher's solution to its corresponding moment in history. This was important — I didn't want the story to feel like a loading screen. Each fragment earns its place because the player just cracked something to get there.

What I'd Build Next

With more time I'd add: audio narration for the fragments, a global leaderboard by completion time, and a second "hard mode" where the ciphers rotate each day based on the actual solstice date in different hemispheres.

This game was created during the June 3–21 jam window as a new submission for the challenge.


Prize Category

Best Ode to Alan Turing

Dawn Cipher honours Alan Turing at every layer — not just aesthetically, but mechanically.

The game's four cipher types reference his actual work: Caesar shift ciphers are the foundation of substitution cryptography that Bletchley Park built on; Morse code was the signal medium of the era he worked in; binary-to-ASCII speaks to the computing model he theorised; and the Turing Test — his most famous intellectual contribution — is the final level.

The narrative fragments tell his story directly: his arrival at Bletchley Park, his birth in June 1912, the 61-year delay between his conviction and his pardon, and the apple found beside him on June 7, 1954. The game ends on a quote from his 1950 paper Computing Machinery and Intelligence — the paper that introduced the Turing Test to the world.

The light-and-darkness mechanic is also intentional. Turing worked in the dark — classified, hidden, erased. The solstice is the day with the most light. Finishing the game before the sun sets is a small act of illumination.

Best Google AI Usage

Level 4 — The Question — integrates the Gemini API as an optional live mode for a real, dynamic Turing Test.

ENTITY-1 is given a system prompt that keeps them in character throughout the conversation: enigmatic, thoughtful, referencing June and the solstice, never confirming their nature. In Gemini mode, every conversation is unique. The full message history is passed with each API call so the AI builds context and remembers what was said earlier in the session.

The integration tries gemini-1.5-flash first, falling back through gemini-1.5-flash-latest and gemini-pro if needed — this makes it robust across API availability. If all models fail, the game surfaces the error directly in the chat and switches back to scripted mode so the player can still finish.

What makes this Google AI usage meaningful rather than cosmetic: the Turing Test is not a bonus feature. It is the fourth and final cipher. It is the mechanic that ties the whole game together. Alan Turing invented the test to ask whether machines could think. Sixty years later, Gemini can step into the conversation. The solstice is the day we find out.


Thanks for playing. The cipher can be broken.

Top comments (0)