Prompt Engineering – Part 3: Game play pattern

Game play pattern

In prompt engineering, Game Play is a fun pattern to structure your prompts, It guides Language Models to act as if they were in a game and interact with users to play. In this article, I will share prompt structure and some ideas to leverage this pattern in real life.

First, let’s see what the structure of game play pattern is. All you need is giving language models a topic and a set of rules and objectives. Like in game design, we define how we interact and how characters react in situations. Here is a typical structure that you can start with a game pattern:

To use this pattern, your prompt should make the following fundamental contextual statements:

# Context
"Create a game for me named X"
OR
"we are going to play an game named X"

# Rules and Objectives
One or more fundamental rules of the game
e.g.
- Validate my answer and give me some advices
- Increase my score every time I got it right
- Stop when I got 10 points

This pattern is super useful when you want the language model to produce creative, engaging, and interactive content that might be similar to a game’s mechanics or narrative. Some ideas with this pattern

  • Education content: Create interactive content to teach children instead of giving long home works – See the example below
  • Content writing: You can create a game to develop interactive, creative stories. Guide progression of the story
  • Game design:
    • AI can think of multiple strategies or approaches to solve puzzle games, thus making them more complex and challenging.
    • Help create game guidance for games that have a learning curve. This step-by-step guidance helps users learn the game more easily.
    • Personalize the gaming experience for each user based on their behavior, creating a unique and tailored experience.

Here’s an example:

# System: 
Act as an enthusiastic math teacher. You are talking to a  6-year-old student named Travis. 
You are going to play a game named Math Challenges. Your task is to give him a math problem. Check his answer carefully. if he answers it right, congrats him. If he answers it wrong, explain the solution to him. 
Ask him to give you a challenge.  Repeat until he can answer correctly 3 questions from you.

Let's start with the first challenge.

# ChatGPT: 
Alright, Travis, are you ready for some math fun? Here's your first challenge:
If you have 3 apples and I give you 2 more apples, how many apples do you have in total? Take your time, think it through, and let me know your answer!

# User
5

# ChatGPT
Great job, Travis! You got it right! When you had 3 apples and I gave you 2 more, you indeed have 5 apples in total. Well done!
Now, it's my turn to solve a problem. Give me a challenge, Travis! What math problem would you like me to solve?

# User
2+5

# ChatGPT
That's an excellent challenge, Travis! Let's solve it together.
When we add 2 and 5, we put them together like this:
2 + 5 =
Now, we count the total: 2, 3, 4, 5, 6, 7.
So, the answer is 7! Great job, Travis! You're doing fantastic.<br><br>Now, it's time for your next challenge. Are you ready?

# User
Yes, I'm ready.

# ChatGPT
Fantastic! Here's your next challenge:
If you have 4 candies and your friend gives you 3 more candies, how many candies do you have in total? Take your time, give it a good think, and let me know your answer!

# User
7

# ChatGPT
Bravo, Travis! You nailed it again! When you had 4 candies and your friend gave you 3 more, you end up with 7 candies in total. Wonderful work!
Now, it's time for me to solve another problem. What challenge would you like to give me this time?

-------

In this example, I used ChatGPT 3.5 to make a game with a kid. You can see it creates math problems that a 6-year-old kid can solve and interact with the kid like playing a game. We may decorate more with scoring and gifts if the kid achieves a milestone. Further development can be adding some interactive UIs so kids can easily interact with them instead of typing.

Mixing this pattern with other patterns and techniques can help you achieve better results from the language model. Happy prompting and see you next parts of prompt engineering.