DEV Community

Adam
Adam

Posted on • Edited on

Interesting take on how to use AI to unlock alternate gameplay styles

The lessons from integrating vision AI into competitive drawing games

The Challenge

So I had this mad idea to build a game where AI would judge people's drawings in real time. Turns out getting machines to understand human creativity is properly tricky.

The main problems were getting the AI to analyze drawings quickly, give decent feedback, and somehow keep things fair when everyone draws completely differently. Oh, and do it all without going bankrupt from API costs.

How It Works

The concept is straightforward. Players get thrown into rooms together, given a prompt like "draw an elephant", and race to sketch it out. Meanwhile, an AI judge watches everyone draw and makes guesses about what each person is creating.

The tricky bit is that the AI needs to figure out what you're drawing before you finish, provide entertaining commentary, and then fairly decide who wins when time runs out.

The Architecture Breakthrough

Instead of building some complex separate AI service, I made the AI another participant in the game room. It joins like any other player, watches the drawing updates, and chats back with commentary.

This meant I could use all the existing multiplayer infrastructure. Real time communication just worked, audio streaming for the AI's voice was already there, and if the AI crashes it can just rejoin like any player would.

Making It Affordable

My first prototype cost about 15p per game. After some serious optimization, I got it down to about 2p.

The breakthrough was realizing most drawing updates don't actually change what the AI sees. Someone adds a tiny line to their elephant drawing, but it's still obviously an elephant. So I started caching results based on the content.

I also only analyze when something meaningful changes, not on every brush stroke. Batch up small changes and only call the AI when there's been enough of a shift to potentially change the guess.

Keeping Things Fair

If you're not careful, the AI can get biased by seeing other players' drawings or knowing who drew what. The solution was to analyze each drawing completely independently.

The AI gets shown one drawing at a time with zero context about who drew it or what other people are drawing. This keeps things fair but means more API calls, which costs more money. There's always a tradeoff.

Smart Winner Detection

You can't just do exact string matching because people describe things differently. If the prompt is "car" and someone guesses "automobile", that should count as correct.

I ended up using the AI for this bit too. Give it all the guesses and the target prompt, and it decides who got it right. Much better than trying to code up every possible synonym.

The AI's Personality

The AI needed to be more than just a functional system. It needed to be entertaining. I went with a HAL 9000 vibe because it's brilliant for a space-themed game.

Short, precise commentary that's slightly unsettling but oddly charming. The key was keeping it brief but memorable enough that people look forward to what the AI says next. Getting this right turned the AI from a tool into a character.

The Technical Reality

Vision AI isn't instant. It takes 1-3 seconds to analyze an image, which feels forever in a fast-paced game. The solution was to decouple everything so players see immediate feedback while AI works in the background.

API providers have rate limits, AI services fail, networks drop. You have to design for all of this from day one or your game becomes unusable.

The Results

The system now handles 12 concurrent players, responds in under 2 seconds, stays up 99.7% of the time, and costs about 2p per game. Not bad for something built in spare time.

What I Learned

Keep things fair. The moment players think the AI is biased, your game is dead.

Cache everything. Vision AI is expensive, and most of the time you're analyzing stuff you've seen before.

Personality matters. The AI's character is what people remember.

Everything breaks. Design for failure from day one.

Good enough wins. Don't obsess over perfect quality. Find the sweet spot between cost and performance.

Where This Goes Next

The possibilities are exciting. AI that adapts difficulty based on skill, different personalities for different game modes, maybe even AI that helps with the drawing process.

There's also loads of potential outside gaming. Educational tools, creative platforms, accessibility features. The technology is all there now.

Give it a go if you're thinking about building something with AI. The tools have never been better.

Experience It Yourself

Want to see AI-powered drawing judging in action? Try it at artbitrator.10kv.games - no downloads or registrations needed, just jump in and start drawing!

Tags: #ai #vision #gamedev #webdev #multiplayer #drawing #realtime #online-games #artificialintelligence

Top comments (0)