next up previous
Next: GAs for Optimization Up: l3 Previous: Issues

GAs for Maze Puzzles

    +----------------+                          Representation:
    |0,3            G|  +--------+         +-+     Sequence of directions:
    | +-------+ +----+  |        |         | |     N^, E>, W<, Sv
    | |       | |       |  +-----+         | |
    | |       | +-------+  |          +----+ |  Solution:
    | |       | +----------+          |4     |     Gene that leads from S to G
    | |       | |                     | +----+
    | |       +-+                     | |       At each decision point in maze,
    | |                               | |          look up next direction.
    | |                               | |  +-+
    | |                               | |  | |  N E W S W E
    | |                               | |  | |
    | |   +-+                         | |  | |  Fitness Function =
    | |   |2|                         | |  | |     distance at end from goal
    | +---+ +--+                +-----+ |  | |     (#steps)
    |         1|                |       |  | |
    +-----+ +--+                | +---+ |  | |  Note:  make gene long to give
          | |           +-+     | |   | |  | |     slack
    +-+   | |           | |     | |   | |  | |
    | |   | |        +--+ |     | +-+ | +--+ |  0) EWWNNEWWSWNNWWW
    | +---+ |        |    |     |   | |      |        f=43 (1,1) 15 moves
    |       |        +--+ |     +---+ +----+ |  1) WSWNEESSESWNENE
    | +---+ |           | |                | |        f=43
    | |   | |           | |                | |  2) SNEESEWWNNNSEWN
    | |   | +-----------+ +----------------+ |        f=43
    | |   |                 S                |  3) EEWWSNNSENWNENW
    +-+   +----------------------------------+        f=43
                                                4) WEEWSENWSWWSNEN
                                                      f=42

                                                Takes 40 generations to solve