0

I'm currently working on a project where I am using a basic Cellular Automata and a Genetic Algorithm to create dungeon-like maps. Currently, I'm having an incredibly hard time understanding how exactly crossover works when my output can only be two states: DEAD or ALIVE (1 or 0).

I understand crossover conceptually - you find two fit members of the population and they exchange genetic material, hopefully producing a fitter offspring. I also understand this is usually done by performing k-point crossover on bit strings (but can also be done with real numbers).

However, even if I encode my Dead/Alive cells into bits and cross them over... What do I end up with? The cell can ONLY be Dead or Alive. Crossover will give me some random value that is outside this range, right? And even if I were to work on floating point numbers, wouldn't I just end up with a 1 or 0 anyway? In that case, it seems like it would be better to just randomly mutate Dead cells into Alive cells, or vice versa.

I've read several papers on the topic but none seem to explain this particular issue (in language I can understand, anyway). Intuitively, I thought maybe I can perform crossover on NEIGHBOURHOODS of cells - so I find 2 fit neighbourhoods, and then they exchange members (Neighbourhood A gives 4 of it's neighbours to Neighbourhood B for example). However, I have not seen this idea anywhere, which leads me to believe it must be fundamentally wrong.

Any help would be greatly appreciated, I'm really stuck on this one.

Ryan
  • 1
  • 1

1 Answers1

0

A lover of dungeon games and Genetic programming here :)

I think you misunderstood the concept of crossover. On your Cellular Automata, you must have genetic information (chromosomes) in such a way your system decides if the matching cell is Dead or Alive. The state of the cell is the output of your system.

You perform the crossover genetic operator between two-parent chromosomes by mixing their genetic information. As a result, you obtain a new chromosome that encodes the map in a way similar to both parents. The new state of your cells is obtained by running the new chromosome to re-map your scenery.

The crossover gets you a new chromosome to map your dungeon, it does not give you new states for the cells. To get the new states, just run your new chromosome.

The state of your cells would be the phenotype, the way your chromosome is manifested. Your chromosome is the model that decides if your cell is dead or alive. I am not concerned about the model you are using. For instance, you are using a Neural Network with two input nodes. One input node receives the X coordinate of the cell in the grid, and the other node receives the Y coordinate. The output node is a binary value: DEAD or ALIVE. This Neural Network has a certain number of hidden layers and weights that are encoded in your chromosome. By performing the crossover operator you create a new way to connect the neurons, which is in between both parents. But in order to know the new state of each cell, you need to pass the coordinates again to the Neural Network. Maybe checking NEAT algorithm by Stanley clarifies the crossover process: http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf

In case you do not have any model that encodes the state of each cell in the map, your genetic information is directly the state of each cell. In this situation, you could split your parent grids into smaller ones, 10x10 grids for instance. Then run through the map in tiles of 10x10 and choose randomly if you pick the matching tile from parent1 or parent2.

I hope this helps!

Alberto

  • Thank you for the explanation. I am still a bit confused on one thing - what is the 'chromosome' in this context? I am creating 100x100 grids of cells that can be ALIVE or DEAD - is the WHOLE grid the chromosome? Therefore, crossover would be mixing 2 different 100x100 grids together to produce a new grid that is hopefully better than the two it was made from? – Ryan Apr 30 '20 at 15:44