Showing posts with label Simulation. Show all posts
Showing posts with label Simulation. Show all posts

Wednesday, February 16, 2011

Algorithms in Action: Genetic Algorithm

  Artificial intelligence uses a great number of algorithms to perform various functions required by the AI. An algorithm is a structured set of logical instructions to reach some solution to a problem. One such algorithm is a genetic algorithm, a search heuristic that mimics heredity to explore various solutions based on the fitness, or correctness, of each element in a generation. Heuristics are experience based approaches that utilize previous knowledge for problem solving or learning, such as a rule of thumb or trail and error. BoxCar2D has been created to give a very good visual on how the genetic process works.
  Genetic algorithms follow a flow not unlike biological genetics to simulate evolution of a system. An initial population is created, generally randomly, and each element of that population is set through a fitness test. After these tests are run, a percentage of the population that is deemed most fit is selected and allowed to "breed." This select division of the population mix portions of their code together to generate a new population of children that will hopefully improve overall fitness of the new population. Along with the mixing of the genetic code the algorithm can introduce mutations to a percentage of the next generation, randomizing different segments of the code to introduce new traits and to prevent an evolutionary dead end.
BoxCar2D in action
  In the BoxCar2D simulation, the user can specify a few traits of the car and watch it evolve. The fitness testing of the car is based on how far the car can go and how fast. The best few are selected and pass on their traits to the next generation and the pattern continues. The user can affect the selected traits by up or down voting cars and changing the mutation rate, which can affect body shape, wheel size, or wheel placement. The graph that populates gives the user a look at how the generations do on average compared to the fitness threshold for it. Take it for a drive and see how it works.