DEV Community

Cover image for ♟️ Chess FEN-tastic: From Screenshot to Playable Chess Position in Seconds with Gemma
pan
pan

Posted on

♟️ Chess FEN-tastic: From Screenshot to Playable Chess Position in Seconds with Gemma

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

My friend recently started learning chess seriously.

He started reading chess books and watching grandmasters play, and there was one problem that kept coming up.

Almost every chess book, whether it's about theory, tactics, or positional chess, is filled with lots of positions to study — diagrams showing a position and asking you to understand the idea, find the move, or analyze what happens next.

But there’s a frustrating gap between seeing the position and actually analyzing it on a digital board.

He'd see something like this:

“White to move. Find the best continuation.”

Great.

Except the position is sitting there as a picture in a book.

To analyze it online, he has to manually recreate the position:

Find the board → identify every piece → place every piece → check the position → finally start analyzing.

Do that once? Fine.

Do it for hundreds of positions across multiple chess books?

Yeah. No.

That was the problem I wanted to get rid of.

So I built Chess FEN-tastic, using Gemma 4 Cloud to turn chess positions into structured, playable positions.

And yes, I know the name is a little... supercalifragilisticexpialidocious.

That's exactly why I chose it. Chess FEN-tastic is supposed to make something tedious feel ridiculously simple — so I wanted a name that was just as ridiculously fun.

Bring any two-dimensional chess position to a digital, playable board in one click — in 3–4 seconds.

Instead of manually rebuilding the position, you simply select it.

Gemma sees the board. Python converts it. Lichess makes it playable.

And suddenly that annoying gap between reading about a position and actually analyzing it on a board disappears.

Demo

🔗 Demo Video

Code

🔗 View the source code on GitHub

How I Built It

The interesting part of Chess FEN-tastic isn't generating FEN.

The real challenge is understanding the chess position inside the image.

A human can look at a chess diagram and immediately understand what's happening.

A computer sees pixels.

That's where Gemma 4 Cloud became the heart of the project.

I give Gemma the actual screenshot of the chess position and ask it to reconstruct all 64 squares.

It identifies:

  • ♔ Which squares contain pieces
  • ♟️ What type of piece is there
  • ⚪ Whether each piece is white or black
  • ⬜ Which squares are empty
  • 🔄 Which side is to move

Instead of asking Gemma to directly produce a FEN string, I have it return a structured representation:

a8: black_rook
b8: empty
c8: black_king
...
h1: white_rook
side_to_move: white
...
Enter fullscreen mode Exit fullscreen mode

This is an important design choice.

Gemma interprets. Python formalizes.

Gemma handles the part that requires visual understanding.

Python handles the part that should be deterministic.

The pipeline becomes:

       CHESS POSITION
             │
             ▼
        📸 SCREENSHOT
             │
             ▼
      🧠 GEMMA 4 CLOUD
             │
             ▼
     64 SQUARES RECOGNIZED
             │
             ▼
      STRUCTURED POSITION
             │
             ▼
       🐍 PYTHON → FEN
             │
             ▼
       ♟️ LICHESS BOARD
Enter fullscreen mode Exit fullscreen mode

The AI isn't just sitting on top of the project as a chatbot.

Visual recognition is the actual core problem.

Without understanding the image, there is no position to convert.

What I really liked about using Gemma here is that I could take a powerful vision-language capability and apply it to a very specific problem.

I didn't want to build another generic AI assistant.

I wanted to solve a very small but surprisingly annoying problem:

How do you turn a chess position that a human can see into a chess position that a computer can use?

Gemma acts as the bridge between those two worlds.

It takes something visual and ambiguous — an image of a chessboard — and turns it into structured information my program can work with.

And the result is remarkably simple:

Image → Gemma → structured position → FEN → playable board

One screenshot.

One model.

One structured output.

One playable position.

That's what makes Gemma so important to Chess FEN-tastic.

Why Does Open Innovation Matter?

The biggest reason open innovation mattered for this project is accessibility and control.

I wanted to build a focused tool around a vision-language model without having to build an entire computer-vision system from scratch.

Gemma gave me a model capable of understanding the visual input, while Ollama provided the interface for integrating the model into my Python application.

That separation made the project possible as a small, focused experiment:

I could concentrate on solving the chess problem instead of reinventing visual recognition.

It also means the architecture isn't tied to a single application-specific chess API. The model interprets the image, while my own code controls the structured representation, validation, FEN generation, and final output.

The result is a simple combination of open technologies solving a very specific real-world problem.

Prize Categories

  • Best Use of Gemma — The heart of the project. Gemma turns a visual chess position into structured data, making the entire Image → FEN → playable board workflow possible.

Top comments (1)

Collapse
 
ayuzz10p profile image
pan • • Edited

P.S. It was just me all along. 😭 (jk)

Where Is My Mind? — Pixies

youtube.com/watch?v=6VG6gIvcjU8