Code Your Ride

Grades 5-12
60 min
Animal ScienceComputer Science

If you are a horse-lover, rider, or trainer and have an interest in computer science, then this activity is for you! Apply computer coding skills to design, test, and redesign a horse-riding pattern. But don’t worry— having a real horse is optional.

In this activity, you’ll learn the definitions for pattern recognition, abstraction, and algorithms in computer science. You’ll then use what you learned to design a pattern for horse riding.

Paper (graph paper is best)


Toy horse or paper to make an origami-style paper horse (optional)

Working with Horses

One of the most traditional 4-H project areas involves working with horses. Some youth spend many hours training with their horses to develop riding skills and control. Equestrian is the name for a rider on horseback, as well as the word for anything relating to horse riding. There are several types of 4H riding projects, including horse riding events and horse shows. These are split into different types of riding methods.

No matter the riding method, equestrians must follow patterns to train and compete with their horses. Below is a pattern example for Western Riding.

Here’s how equestrians read this pattern!

  • The Course: In the drawing of a horse-riding course above, notice the symbols and different styles of lines that make a pattern for the horse and rider to follow.
  • Legend: At the top of the example is a legend—also called a key—which tells you how to read the patterns on the riding course. The riding pattern legend uses symbols for horse riding activities. You’ll learn more about symbols later.
  • Step-by-Step Instructions: At the bottom of the example is a numbered list of step-by-step instructions. Each step includes one action the rider and horse will take on the course. The numbers indicate the order in which the actions will be taken.
Did you know?

There are many horseback riding styles, including dressage, western pleasure, show jumping, endurance, and rodeo-riding skills. Almost all types of equestrian competition include training using patterns. One of the most complicated kinds of horse training is dressage. It focuses on training the horse to move very smoothly based on subtle signals from the rider, and it is even an Olympic sport!

Horseback Coding

Now that we know a little more about horseback riding, let’s talk about what it has to do with coding. We’ll use the pattern example we looked at in the last section and connect it to some common coding concepts.

Course: The picture of the course shows the pattern a rider would need to follow. Patterns in coding are just like patterns in real life: something that repeats over and over again.

Legend: The legend in a horse riding pattern uses symbols for different horse riding activities. The symbols help equestrians abstract what movement they should do with their horse. Abstraction is the process of pulling out the important parts of a problem so you can focus on them.

Step-by-step instructions: Riders are given step-by-step instructions on how to complete the pattern. In computer science, step-by-step instructions are called algorithms.

In coding, an activity that repeats itself can be set up as a loop so that you don’t have to write the same code or repeat the same instructions over and over. Check out the example horse riding pattern above. Does the example pattern contain any loops?

Try It!

Before you write your own algorithm for horse riding, try out one of the example worksheets from this lesson. Having a horse as a model will help you try this pattern. You can either find a toy horse, or you can create an origami paper horse to walk through the riding pattern.


Did you know?

If you’d like to make an origami horse, search the internet for how-to videos!

After you walk through the course, ask yourself the following questions:

  • Are any of the steps confusing?
  • If you were the rider, how do you think you would communicate with the horse to tell it what to do next?
  • If you were helping a new rider, would you add or change any of the instructions to make the riding pattern easier to understand?

Reading the riding patterns can be confusing. Reach out to friends or family if you need help. Even if they don’t know anything about riding patterns either, talking through a problem with someone else can make you feel better and solve the problem!

Coding Your Own Pattern

Imagine that you are a computer scientist tasked with writing a computer simulation for horse riders to use to learn a course pattern you have designed. As part of your design, you will create the three parts shown in our example: a legend, a drawing of the course, and the algorithm steps. Follow the steps below to get started!

1. Plan the riding pattern for your course.
  • What riding activities would be part of your pattern for the horse?
  • Would your pattern design include looping, or repeat itself?
  • Will your plan be long or short?

At the end of this step, you should have a course and a path drawn.

2. Create and draw your riding pattern legend.

Design your legend to help riders understand which riding activities the horse will do in the course. This legend is your programming language. If this were computer code for a simulation, you would use specific words or symbols that the computer could understand to tell it what to do. You can use the symbols from the pattern example or create some of your own. At the end of this step, your path should have symbols added to show which horse riding activity the rider and the horse should do at each part of the path.


3. Create a riding algorithm.

Write the steps the rider and horse will complete on the course. If you need help, refer to the steps at the bottom of the Western Riding Pattern examples. At the end of this step, you will have a completed riding pattern!


4. Test your riding algorithm.

Have someone test the riding algorithm you created. Does the horse do what you expected? Do you need to change, or debug, your riding code to make it clearer?

Redesign Time!
  • Based on what you learned from testing your riding pattern, make changes to your algorithm to make it even better!  What should be added? Are there parts that are confusing that you want to change or take out?
  • Imagine you are working with a very young rider. Are there things you would change to make it easier for them to understand?  Would you want to create a simpler pattern?
  • What would you change for a very experienced rider?


You have learned about using patterns to create algorithms for horseback riding. Can you think of other ways algorithms can be used in agriscience?


Were others able to follow your horse pattern?  Was it difficult to adapt for a younger person or beginning rider?


Why are patterns important for creating algorithms?

What patterns might be used in planting crops in a field or garden? Are there any steps that are repeated? How could looping help in planting? Check out Code Your Garden on CLOVER to explore this more!

Are there any patterns you recognize in your daily routine?  What could you change in your algorithm to make your day run more smoothly? Explore Code Your Morning Routine on CLOVER to learn more about computational thinking skills.

Though they may not always seem related, your passions can tie in to your career! Jen Macklin grew up with horses. She babysat and tutored to earn money to take horse riding lessons when she was a little girl, and her spark for horses still burns bright!

Today, she’s using her computer science degree to work on an app that helps detect a deadly disease called laminitis in horses. Detecting the disease early on allows vets to treat the horses, so Jen’s app can save the lives of lots of horses.


Code Your Ride

Did you enjoy this activity?

No endorsement by 4-H is implied or intended. 4-H is the youth development program for our nation’s cooperative extension system.