|
Artificial Insects
(a JAVA exercise) |
![]() |
I have provided a somewhat lengthly description of these little critters below.
|
|
Simple: Use the scroll bars at the bottom and left to see different parts of the field. The button tags at the top indicate the current status of the display. Introduction The artificial insects presented here are the result of a JAVA program (simple description below) which generates a field (a territory so to speak) on which a number of nearly identical artificial insects can roam. Each insect has a visual system which, for the most part, keeps it from running into obstacles and other insects. Each also has a scent detection system which allows it to follow scent trails left by itself or other artificial insects. Each also has a parameter which keeps track of artificial food in its system; its food seeking behavior is dependant upon this parameter. Even though the artificial insects are quite simple they exhibit some rather interesting behavior. The Field The field on which the artificial insects roam is rectangular in shape and is graphically represented as such. So that the artificial insects do not wander too far a field the program automatically turns the insect back toward the field boundary once the insect has left the field. This turning process takes presidence over all other possible insect behavior and is thus truly artificial but necessary. All other artificial insect behavior exhibited on the field is completely controlled by each individual insect. The field also keeps track of scents which may be deposited by the artificial insects. The scent information for the immediate vicinity of each artificial insect is conveyed to each artificial insect so that the insect may react accordingly and follow scent trails or not. There are a number of obstacles on the field. Each obstacle has a predetermined size and light intensity. This information is also conveyed to each artificial insect so that the insect’s eye pixels can be set to the appropriate level to simulate the artificial insect seeing the obstacles. The other artificial insects on the field are also visual obstacles, and since the vision system of the insects is such that the insect tries to avoid obstacles the insects try to avoid each other also. The field also has one location which is the source of artificial food. When the food-depleted artificial insect arrives at this location (whether by chance or design) the food level of the insect is automatically increased to a fixed value. The Artificial Insect Each artificial insect consists of six articulated legs, a vision processing system which has two eyes, a scent processing system which receives information from the field with regards to scents in the immediate field vicinity, and some rather simple data processing algorithms to control the legs. The Legs Each leg consists of an upper leg and a lower leg. The upper leg is attached to the body of the artificial insect at the hip and the lower leg is attached to the upper leg at the knee. The foot is at the end of the lower leg. The upper leg can be raised and lowered, and swung forward and backwards. These two modes of motion allow the leg to raise, swing forward, lower and swing backward, thus simulating a stepping motion forward. Stepping backwards requires the reverse process. The artificial insect has routines to coordinate the motion of the six legs. Straight walking uses the two tripod method. Three legs are planted on the ground and swung in unison either forward or backwards while the other three legs are raised and swung in the opposite direction. Turning is accomplished by keeping some legs fixed, as pivot points, and allowing other legs to walk forwards or backwards. Each artificial insect has routines which allow the insect to walk straight forwards or backwards, turn to the left or right while making two steps forward, or pivoting to the left or right while making a step turn forward followed by a step turn backwards. The legs can also be idle, allowing the artificial insect to pause in its motion. The locations of the hips are determined by the size and shape of the body of the artificial insect. The bodies are rectangular and of varying lengths and widths. The leg lengths are determined by the lengths of the bodies. By varying the body length and width parameters it is possible to have a variety of sizes and shapes for the artificial insects. The length and width of a given artificial insect will somewhat affect the behavior of that insect. The width of the insect determines the spacing of the eyes, and thus if the width is too small the vision system has difficulty using parallax to determine the presence of obstacles, and the insect is prone to hitting obstacles. Extremely long artificial insects have very long strides and have difficulty stopping before they crash into obstacles. Extremely short insects have short legs and thus do not move very far during a single leg action. Combining short with wide produces an insect which can not turn very sharply. Since the legs to not move the one side of the insect very far during a single leg action, that short distance combined with the wide body (and hence long distance to the pivot leg) leads to a large turning radius. Wide insects however are very sensitive to obstacles in front of them and often turn away from them even at fairly large distances. The eyes and body of the insect are carried by the insect. The leg motion is the final response to most of the data processing which occurs in the artificial insect. The vision system sends messages to the leg controls which direct the insect to avoid obstacles, and the scent system sends messages to the leg controls which direct the insect toward the source of artificial food. The Vision System Each artificial insect has a vision system. The system has two identical eyes. Each eye has two artificial light receptors, one pointing to the front and right, and the other pointing to the front and left. The eyes are physically separated by the width of the insect so that one set of eye receptors sees a slightly different field than the other. Simply by comparing light intensities in the left eye receptors with the intensities in the right eye the artificial insect in most cases is able to detect obstacles or other insects that are close and in front of the insect. Since one receptor in each eye points right while the others points left the vision system can tell whether the obstacle is to the left or right of forward, and sends a warning to the artificial insects leg control system so the insect will turn to avoid the obstacle. This rather simple vision system is quite successful in keeping the artificial insect from walking over obstacles in the field. There are situations however where the insect turns to the left to avoid one obstacle only to be instructed to turn to the right to avoid another. This leads to a very repetitive pattern in which the artificial insect is stuck in a oscillations of turns to left followed by immediate turns to the right. To get the insect unstuck from the pattern the leg control system has an artificial nervous fatigue. After a few repetitions there is a parameter change which increases the probability of backing up rather than of turning. This is enough to keep the artificial insect from getting caught in an endless repetition of turns. As the insect starts walking and not turning the parameter reverts to the original value. The vision system performs no other functions. It only detects forward obstacles by a rather simple algorithm or comparison of light levels in the two receptors in the pair of eyes, and sends a simple signal to the leg control system of turn left or right as need be. Scent Processing Each artificial insect has the ability to get and hold artificial food. Food is dispensed at one location on the field. In order to get food the insect must be out of food and at the location of the dispenser. When that happens the insect is programmed to stop until its food supply is replenished. It then leaves that location and leaves a scent trail behind it indicating it has recently been fed. The trail diminishes in strength as the insect uses up its on-board food supply and also fades with time. The scent trail allows other insects to find the food dispensing location. An insect which is out of food is programmed to follow a food scent trail in the direction of increasing intensity of the scent. With a little luck the hungry artificial insect finds its way to the food source. There is a second scent system to allow the artificial insects to find their home on the field. When they leave home they leave a separate scent trail behind so that others can follow it to home. They do have a Mission If you let this applet run for awhile (perhaps 20 -30 minutes) eventually the artificial insects find their home, leaving scent trails from there as they leave, and will start treking between home and the food source until the scent trail is lost. Click the “Draw Bugs” button to see the scent trails. A little (very little) description of the JAVA programming This is obviously an applet. The applet (Field) creates any number of objects of the Bugs class and a number of objects of the Markers class. Each object of the Bugs class creates six objects of the Legs class, an instance of the VisionSystem class, and two instances of the ScentSystem class. The Legs class object takes care of the articulation of the legs through methods called by Bugs class objects. The VisionSystem object creates two instancse of the Eye class objects. Eye class objects have information set by the Field dependant upon the geometrical location of obstacles (Markers class objects), and other artificial insects (Bugs). This information is used by the VisionSystem of each Bugs to avoid obstacles and other insects. One ScentSystem object takes care of the food scent, and the other the home scent. Information is set by the Field as to the location of the home and food. This information is processed and given to the Bugs class objects so they may follow the scents (or not). |