Tic-Tac-Toe and the Art of Gemini Prompt Engineering

Leon Nicholls
5 min readMar 7, 2024

--

Have you ever wondered what you could learn from a simple tic-tac-toe game? It turns out quite a bit — especially when you’re against a cutting-edge language model like Google Gemini. Join me on a surprisingly fun journey as I attempt to teach Gemini this classic game and the powerful lessons about communicating with LLMs I uncovered.

Note: This article spotlights techniques for the Google Gemini Advanced chatbot (a paid service), but you can also apply these concepts to the free version.

The Tic-Tac-Toe Challenge

Round 1: The Code Conundrum

Let’s play tic-tac-toe,” I type, figuring a classic game would be fun to try with Gemini Advanced. Imagine my surprise when Gemini spits back a block of Python code for generating a game board. Cool? Yes. What did I ask for? Not really.

Round 2: Refining the Board

So, I need to be more specific. “Okay, Gemini,” I say (well, type), “Let’s play tic-tac-toe. Represent the game board in a code block, but don’t show any code.” Success! A neat little grid appears. But as we “play” (aka, me putting Xs and Os in the right places), a new problem pops up. I get three Xs in a row and…nothing. Gemini doesn’t even blink and keeps playing. This language model needs some serious tic-tac-toe schooling.

Round 3: Victory!

This time, I changed tactics. Before jumping into the game, I gave Gemini a quick rule refresher: “Let’s play tic-tac-toe. Represent the game board in a code block, but don’t show any code. Please give me a summary of the game rules and then start a game.” You get the picture. And guess what? It works! We played a few rounds, and Gemini did great.

For the Win

The point is that with each try and a little tweaking of my prompts, Gemini got better. This surprisingly simple game hammered home the importance of clear instructions and how a little context goes a long way when talking to an AI.

Important Note: Google Gemini constantly evolves, so your results may vary.

Key Takeaways

Okay, that whole tic-tac-toe adventure wasn’t just for fun (well, mostly for fun). It made me realize a few key things about getting the best out of a super-powerful AI like Gemini:

  • Start Simple, Iterate Smart: Don’t try to throw a super-complex task at Gemini from the get-go. Please start with the basics, and let its response guide you. If you need more details, add them bit by bit. Think of it like building a house — you start with the foundation!
  • Specificity is Your Superpower: The more precise and specific you are, the less room Gemini has for clarification. If needed, break tasks down into step-by-step instructions.
  • Context is King: Remember, Gemini doesn’t live in your head. Sometimes, you’ll need to give it some background info. The game rules were the perfect example — don’t assume that Gemini has all the rules “top-of-mind” (check out my article on Gemini’s context window for more details).
  • Learning Loops: Be bold about giving Gemini feedback! Tell it when it gets things right (positive reinforcement!), or gently correct it if it’s off track. This is how any good student learns, even the super-smart AI ones.

Practical Tips & Tricks

Alright, now that we’ve got the basics down, let’s talk about some handy tricks to boost your prompt-engineering skills:

  • Code Blocks for Clarity: If you’re dealing with anything code-related, ask Gemini to format its responses as code blocks. But if you want the result (like that tic-tac-toe board), ask it to hide the code to keep things clean.
  • The Power of Examples: Sometimes, the quickest way to get Gemini on the right track is to show it what you mean. Need a poem in a specific style? Give it an example to spark its creativity.
  • Have a Conversation: Think of your interaction with Gemini as a dialogue, not just a list of commands. Ask follow-up questions based on its answers — you might be surprised by the insights you uncover.
  • Experiment and Have Fun: The best way to master prompt engineering is to play around with it! The more you use Gemini, the better you’ll understand how it ‘thinks’ and how to guide it towards the results you’re looking for.

Applying Lessons Beyond the Board

The thing about those lessons we learned? They can make a huge difference in using Gemini for more serious stuff. Here are a few ideas:

  • Creative Sparkplug: Whether you want to brainstorm story ideas, get a quirky product description, or even write a haiku, the same ideas apply. Start simple, add detail as needed, and let Gemini surprise you.
  • Problem-Solving Partner: Do you have a tricky problem at work or a project that angers you? Frame it clearly for Gemini, offer background details, and see what solutions it suggests. Don’t be afraid to try unusual prompts — sometimes, the most creative solutions come from unexpected places.
  • Be patient. Learning to communicate effectively with an AI like Gemini takes time and practice. Keep going even if you don’t get the results you want right away. Just keep experimenting and learning, and you’ll eventually get the hang of it.
  • Be open-minded. Gemini is still under development, and it’s constantly learning new things. Be willing to try new things and explore different ways of interacting with them. You might be surprised at what you can accomplish.

This is just scratching the surface. The more comfortable you get with prompt engineering, the more you’ll realize how Gemini can support all sorts of projects and goals!

Conclusion

My tic-tac-toe adventure with Gemini was way more than just a silly game. It opened my eyes to the art of prompt engineering — how carefully chosen words can distinguish between a confused AI and excellent results.

Check out my reading list of other Google Gemini articles.

This post was created with the help of AI writing tools, carefully reviewed, and polished by the human author.

--

--