Setting up a simple AI

Because Grunt makes decisions autonomously and mimics an intelligent creature, we can consider his programming to be an example of a simple AI. This means that Grunt is the smartest robot we have made so far!

Recall from the last chapter that the Timmyton's program consisted of one main switch that activated an operating mode based on the brick button that was pressed. Grunt's method is more sophisticated. In order to imitate autonomous decision making, Grunt's programming relies on a series of nested switches. Each switch monitors a different sensor. If the sensor detects that a pre-defined parameter is met, then the corresponding mode will activate; if not, then the program continues down the line and checks the next sensor. If all of the switches return false, Grunt idles and the sensors are checked again.

In the context of programming, nesting a switch refers to the practice of placing a switch within another switch. This is an efficient way to create a complex control system. Nesting many times will create a multi-tiered decision-making process for a robot. In Grunt's program, several switches are nested, with each checking a different parameter on one of the three sensors.

Now that we know about nesting, we can proceed to set up the framework for Grunt's decision-making program.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.144.197