If-Then statements are a fundamental logic used in computer programming. They are how a program makes decisions. They are usually phrased as:
IF "question" THEN "action"
The "IF" part of the statement is followed by a question or equation that the program evaluates such as "Do you own a pony?". The condition statement can be true (if you own a pony), in which case the program takes the action following the "THEN" or it can be false (if you do not own a pony) in which case the program does not take the action. The action can be whatever you need the program to do, for example it could then calculate the amount of hay a pony needs every day. It could even have a series, or list, of actions to take. It could ask you for information like how much your pony weighs and how much work he does every day and then calculate exactly how much you should feed him. This is an example of basic programming, but I want to explain the idea in the more physical world, so lets look at riding.
Horses have very simple brains so their thinking often seems similar to If-Then. When you are riding a horse he is constantly listening for a new command from you. IF he hears or feels that command THEN he takes the action you have requested.
For example your horse should be trained to know that IF you squeeze with your legs THEN he should go faster. He should also know that IF you pull back on the reins THEN he should slow down.
When programming a computer, the commands are usually written in a programming language. However, when designing a program, programmers often write out their commands in a shorthand called "pseudo code" before translating them into the language they want.
Writing the above horsey examples in pseudo code would look something like this:
IF legs = squeeze THEN go faster
IF reins = pull THEN slow down
A couple of additions to the IF condition statement are AND and OR. Both are used to combine conditions for evaluation. If 2 conditions are joined by an AND then they both must be true for the action to occur. If two requirements are joined by an OR then either can be true for the action to occur.
For example:
IF outside leg = kick OR rider says "canter" THEN canter
In this case your horse would pick up a canter if you are silent and kick with your outside leg, OR if you don't move your legs but you say "canter" to him, OR if you kick and say "canter" at the same time. As long as one or both of these statements is true he will canter.
Here is an example of AND:
IF rider in 'jump position' AND fence in front of me THEN jump
In this example your horse will only jump if you are in jump position on his back AND there is a fence to jump. I have attempted to illustrate the possibilities below.
First, if you are not in jump position and there is no fence then your horse will walk along normally:
Next, if you are in jump position while walking along with nothing to jump in sight, then your horse will just continue to walk along:
Next, if you are sitting in your saddle and you come to a fence, your horse will stop and look confused (At least mine looks confused, he eyes the fence like “who put a fence in the middle of my ring?” Of course Pepper is western trained and not jump trained.):
Finally, if you are in jump position and there is a jump in front of your horse he will jump over it:
As you can see, the only time a horse jumps over a fence is when both conditions are met.
Of course the problem with thinking of your horse as a robot is that you have to be ready for the unexpected. While you are thinking about what to tell him, his brain is running more algorithms like:
IF plastic bag flaps THEN jump straight up in the air and run away
IF other horse = too close AND gait = canter THEN kick
You have to be ready to react and respond if he does anything unexpected.
IF-THEN statements are a very fundamental part of computer programming, but they are a very small part. When you think, your brain uses many different types of logic and thought processes which programmers are trying to replicate in computers and robots. We will be looking into many of these logic concepts in future "Robot Horse" installments.



