Friday, January 11, 2008

The mighty if statement

For all you non-computer programmers out there let me bring you up to speed. The “if statement” is used whenever you want your computer program to branch off in a different direction. Here’s an example:

Seems innocent doesn’t it? But like a festering wound it can become so much more. Science fiction is full of examples of AI system running out of control. Some of them even manage to take over the world and enslave humanity. Although they make for great stories this is highly unlikely.

One technique for creating Artificial Intelligence is to use a rule base. Essentially the rule base is a glorified collection of “if statements”. Here’s an example for a combat mech:

See how specific you have to be? You simply cannot account for every possibility that can occur in the real world. There are just too many unknowns. That’s why it’s easy to trick these kinds of machines, another staple of SF literature. Also if the rule base isn’t designed properly commands can contradict each other causing the poor machine to get stuck in an infinite loop. Remember T3 when the Terminator shuts down because it received programming that contradicted with its main objective of protecting John Conner? That is a perfect example of what I am talking about.

Also in our day-to-day lives the “if statement” can get us into loads of trouble. Whenever we install software we are asked to agree to a EULA. As soon as we click on the “I accept” option we are legally bound to the terms and conditions specified in the license. This means you can be hauled into court if you violate any of those terms.

Guess what? An “if statement” running in the background determines whether or not you have accepted the agreement. So now you know why this mere piece of code is so mighty.
Post a Comment