# What is genetic programming and how ai is used in developing the logic?

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

### Abstract:

Genetic programming is basically a technique that is used to solve the problems with the help of computers. It is used mainly to solve game playing. I have discussed that how genetic programs are used to find the solution to the problem then the example of application used in game playing. After that i have discussed the examples of genetic programs and finally the conclusion to the genetic programming.

### Introduction to genetic programming:

It is a method of solving problems with the help of computers. It generates solutions by going through various steps like natural selection, mutation etc. It provides solution to various problems like that include statistical reasoning, game playing etc. It can be best described as the part of machine learning. Machine learning can be defined as “the study of computer algorithms that improve automatically through experience”.

Now before defining Genetic Programming in detail, we must know what actually these domains i.e. statistical reasoning, game playing mean:

Statistical reasoning: It basically assigns certainty to the uncertain things i.e. numerical values thereby act as a function to summaries the world. In this we use the numerical value to tell how often an exception of some sort is likely to occur. It is said that statistics can be used to prove anything -even the truth.

Game Playing: It is a technique used in various computers and video games in order to provide the illusion of intelligence. It uses AI techniques in a way that there is two player game and the opponent is computer and is basically trained how to tackle the situations i.e coding is done and it plays according to the things taught to it.

Genetic programming performs user's task and hence the algorithms used treat each individual as a computer program. In genetic programming, the representation of computer programs is done in memory in form of trees. The representation of tree is as:

§ Every node constitutes an operator function,

§ Every terminal node constitutes an operand function.

With the help of trees, the mathematical functions are easier to calculate. Consider the example: (3+5)*(4+3).It is represented using tree as:

*

+ +

3 5 4 3

Genetic programming starts with the high level language, identifies the problem and finally finds the solution to the problem. This structure is referred to as tree structure.

### Now how the genetic programming finds the solution to the problems:

It is basically a branch of genetic algorithms but both differs in the way they represent the solution. The computer programs are created in LISP or other computer languages as the solution.

The main steps used by the genetic programming to solve the problem are:

• It initially generates the random compositions of the problem
• Execute each problem and assigns a certainty factor according to its capability to solve a particular problem
• It then creates the new computer programs and performs the following steps:
1. Firstly it copies the best existing programs
2. With the help of mutation, it creates the new program
3. Using the sexual reproduction also called as crossover, it then creates the new computer programs.
• From the above procedure it takes into account the best computer program and designate it as the result of the problem.

Now the question arises that how the mutation and crossover is done. It is done as:

### Mutation: it is an important feature of genetic programming. The mutations can be done in two ways:

1. In this the function can only replace function and a terminal can only replace the terminal.
2. In this an entire subtree can be replaced by another subtree.

Now from this again a question arises that what are function and terminals?

The functions and terminals are the alphabets of the programs to be made. The terminal set constitutes variables and constants of the program and the function constitutes the function of the program. The functions can be mathematical functions like addition, subtraction, multiplication or complex functions.

### Crossover operation:

In this the two solutions are sexually combined to form the new solutions. It uses various methods to select the solution.

### Applications of genetic programming:

If a human is playing some game say snake game he can use his mind and make the guesses and according to that guesses he can pursue the game using the fact that the a moving snake adds the element of pressure and so a human is capable of thinking in a timely manner. But when we use the computer to play the game, computer will have the time to parse the through the program tree and determine the next move. The pressure acts as the limitation to the computer and these limitations restrict the possible number of decision trees that can be generated and so the computer gets the maximum time to determine the next move.

With the help of genetic programming, a computer can be designed so as to produce human competitive results. The effectiveness of genetic programming can be demonstrated from the examples like wall following robot and Pac Man. The programs evolved by them are capable of navigation and task prioritization which are competitive to the results so produced by humans. Genetic programming can produce a program that can produce the best score in the snake game. The explanation of the game is:

### 1) Snake game: Snake game is basically a game when a snake is so designed that it is confined to a rectangular board and it eats food by avoiding the touch of its own body as well as the wall. The problem becomes more interesting because as the snake eats the pieces of food, its body grows in size and it gets more chances to touch its body or the wall.

The initial runs of the game can be explained in a table as:

 Objective To search program that eats maximum pieces of food Terminal set (forward),(left),(right) Function set if Food ahead, dangerahead, dangerright, dangerleft, swap Fitness cases One fitness case Raw fitness Pieces of food eaten Standardized fitness Food consumed-raw fitness Hits Total food consumed Parameters M=5000, G=500 Success 211 hits

### Explanation:

1. Terminal set: Each terminal set i.e forward, left, right act as macro that causes the snake to take the corresponding action. In right, the snake changes its turn to the right, in left, the snake changes its turn to the left whereas in forward, the snake keeps moving in the same direction.
2. Functions: the various functions that are used are:
• If food ahead: if the food lies in the snake's path, the function will execute
• If Dangerahead: if either the snake body or the wall occupies the game square then this function will be executed
• If dangerright: if either the snake body or the wall occupies the square to the right of the snake immediately then the function is executed.
• Ifdangerleft: if either the snake body or the wall occupies the square to the left of snake immediately then the function is executed.
3. Fitness: Genetic programming achieves the high fitness measures on the basis of the function tree of the individuals, in which we measure the high fitness on the basis of the average of the four runs of an individual.

4. Fitness measure: It is measured as the total pieces of food taken minus theactual number of pieces of food eaten.
5. Parameters: the population was set to 5000 and the generation was set to 500. The function's tree size is limited to 150, the parameters are so chosen on the basis of the computer resources available.

The initial stage of the snake is shown diagrammatically as:

The movement pattern used to increase the maximum score is shown diagrammatically as:

### Examples of genetic programs:

Ø Symbolic Regression - it is defined as the process of discovering both functional form of target function and all of the necessary coefficients.

Ø Analog circuit design - it is used in embryo circuit. It is the circuit that is modified and is used to create the new circuit according to the functionality.

### Conclusion to genetic programming:

1. It is field of study in machine language
2. It saves time and constructs the better programs
3. It is based on the principle of genetics
4. Main application is game playing that produces the effective result
5. The future of genetic programming is uncertain.

### Future of genetic programming:

Ø Since genetic programs can be used to design the custom organisms using some future programming languages so the result produced will be more powerful that will continue the more powerful technology in people's hand.

Ø They can be used as an automated invention machine to create new and useful inventions because they can evolve the entities that are competitive with the human produced results.

Ø Genetic programming is capable of creating the programs that are capable of adapting or recreating themselves for open ended tasks.