Answers.Body: <p>The general notion is that of 'Competitive Coevolution' and there are many (maybe hundreds) of academic papers that describe various alternatives.</p>
  
  <p>The excellent (and freely available) <a href="https://cs.gmu.edu/~sean/book/metaheuristics/" rel="nofollow noreferrer">Essentials of Metaheuristics</a> has a whole chapter on the subject.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-20T22:19:35.960Z
Answers.LastActivityDate: 2017-06-20T22:19:35.960Z
Answers.UserDisplayName: NietzscheanAI
Answers.Body: <p>Look up tournament selection
  Tournament selection is a method of selecting an individual from a population of individuals in a genetic algorithm.[1] Tournament selection involves running several "tournaments" among a few individuals (or "chromosomes") chosen at random from the population. The winner of each tournament (the one with the best fitness) is selected for crossover. Selection pressure, a probabilistic measure of a chromosome's likelihood of participation in the tournament based on the participant selection pool size, is easily adjusted by changing the tournament size[why?]. If the tournament size is larger, weak individuals have a smaller chance to be selected, because, if a weak individual is selected to be in a tournament, there is a higher probability that a stronger individual is also in that tournament.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-30T10:50:50.793Z
Answers.LastActivityDate: 2019-01-30T10:50:50.793Z
Answers.UserDisplayName: George
Answers.Body: <p>i'm the main developer of <a href="https://github.com/wagenaartje/neataptic" rel="noreferrer">Neataptic</a>, a Javascript neuro-evolution library.</p>
  
  <ol>
  <li><p>Very effective! Realise that this is how real-life evolution happened as well: we kept on improving against other species, which forced them to improve as well.</p></li>
  <li><p>Very practical, <em>especially if you don't want to set up any 'rules'</em> like you say, it makes the genomes find out what the rules are themselves.</p></li>
  <li><p>Basically, you let each genome in the population play X games against other genomes, I advise you let each genome play against every other genome in the population. An example of scoring would be giving the genome <code>1</code> point for winning, and <code>0.25</code> or <code>0.5</code> for a tie. Each game should always have a result! </p></li>
  <li><p>I'm not sure about this one, as I haven't implemented speciation. </p></li>
  </ol>
  
  <p>I want to give you some examples that I have worked on: </p>
  
  <ul>
  <li><p><a href="https://wagenaartje.github.io/neataptic/articles/agario/" rel="noreferrer">Agar.io AI</a> (neuro-evolved neural agents) - basically, I let neural networks evolve to get the highest score they can in agar.io, by competing against each other! It worked better than I expected.</p></li>
  <li><p>Currently i'm working on new project, a kind of 'cops and robbers' style game.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-20T20:40:29.747Z
Answers.Text: Awesome answer!  (More links would be useful on the basic concepts, since I'm noticing a recent disconnect in that area due the growing accessibility of the methods.)  I favor this approach because I can use guided learning to give my automata some basic axioms, but let their intelligence be a factor of self evolution, which hopefully leads to axioms they themselves discover. :)
Answers.UserDisplayName: DukeZhou
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-13T22:07:42.350Z
Answers.Text: I was going to post examples from Neataptic, but then I saw your answer sir, and I am not worthy :D Nice to e-meet you!
Answers.UserDisplayName: Alexus
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-20T07:45:23.723Z
Answers.LastActivityDate: 2017-06-20T07:45:23.723Z
Answers.UserDisplayName: Thomas Wagenaar
Body: <p>I am developing AI in the form of NEAT, and it has passed certain tasks like the XOR problem outlined in the <a href="http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf" rel="nofollow noreferrer">NEAT Research Paper</a>. In the XOR Problem, the fitness of a network was determined by an existing function (XOR in this case). It also passed another tests. One I developed was to determine the sine at a certain point X in radians. It also worked, but yet again, its fitness was determined by an existing function (sin (x)). </p>
  
  <p>I've recently been working on training it to play Tic Tac Toe. I decided that to determine its fitness, it would play against a "dumb" AI, placing O's in random locations on the grid, and gaining fitness based on whether or not it placed X's in a valid location (losing fitness if it placed an X on top of another X or an O), and gaining a lot of fitness if it won against the "dumb" AI. This would work, but when a network got really lucky and the "dumb" AI placed O's in impractical locations, the network would win and gain a lot of fitness, making it very difficult for another network to beat that fitness. Therefore, the learning process did not work and I was not able to generate a Tic Tac Toe network that actually worked well.</p>
  
  <p>I do not want the GA to learn based off an "intelligent" tic tac toe AI because the whole point of me training this GA is so that I do not have to make the AI in the first place. I want it to be able to learn rules on its own without me having to hard code an AI to be very good at it.</p>
  
  <p>So, I got to thinking, and I thought it would be interesting if the fitness of a network could be determined based off how well it played against OTHER NETWORKS in its generation. This does seem similar to how humans learn to play games, as I learned to play chess by playing against other people hundreds of times, learning from my mistakes, and my friends also increased in their ability to play chess as well. If GA's were to do that, that would mean I don't have to program AI to play the game (in fact, I wouldn't have to program a "dumb" AI as well, I would only have to hard code the rules of the game, obviously). </p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>Has there been any research or results from GA's determining their fitness based off competing against each other? I did some searching but I have no idea what to look for in the first place (searching 'NEAT fight against each other' did not work well :-(  )</p></li>
  <li><p>Does this method of training a GA seem practical? It seems practical to me, but are there any potential drawbacks to this? Are GA's meant to only calculate predetermined functions that exist, or do they have the potential to learn and do some decision making?</p></li>
  <li><p>If I were to do this, how would fitness be determined? Say, for the tic tac toe example, should fitness be determined based on whether or not a network places its X's or O's in viable locations, and add fitness if it wins and subtracts fitness if it loses? What about tying the game?</p></li>
  <li><p>Should networks of the same species compete against each other? If they did, then it would seem impractical to have species in the first place, as networks in the same species competing against each other would not allow a successful species to rise to the top, as it would be fighting against each other.</p></li>
  <li><p>Kind of out of topic, but with my original idea for the tic tac toe GA, would there be a better way to determine fitness? Would creating an intelligent AI be the best way to train a GA?</p></li>
  </ol>
  
  <p>Thanks for your time, as this is somewhat lengthy, and for your feedback!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-20T14:18:50.840Z
Comments.Text: What you're describing is a type of what's known as a coevolutionary algorithm. Googling that should be a useful exercise.
  
  I'd also point out that the general idea of playing against versions of yourself has a long history in the literature around learning to play games. One of the very earliest real success stories in AI was Arthur Samuel's checkers program in 1959. He trained a program to play the game at the level of a very strong human by having it play games against itself, each time improving itself via a mechanism that resembles what we would today call reinforcement learning.
Comments.UserDisplayName: deong
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-20T16:08:30.260Z
Comments.Text: Let's have it clear...try to make your question brief and kept in mind that every one understands it .fast
Comments.UserDisplayName: quintumnia
Tags: <neural-networks><machine-learning><genetic-algorithms>
Title: Could GA's determine fitness by "Fighting" against each other?
UserDisplayName: Jaboyc
ThreadText: # Could GA's determine fitness by "Fighting" against each other?
  
  (Asked by: username_0 on 2017-06-20)
  
  I am developing AI in the form of NEAT, and it has passed certain tasks like the XOR problem outlined in the [NEAT Research Paper](http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf). In the XOR Problem, the fitness of a network was determined by an existing function (XOR in this case). It also passed another tests. One I developed was to determine the sine at a certain point X in radians. It also worked, but yet again, its fitness was determined by an existing function (sin (x)).
  
  I've recently been working on training it to play Tic Tac Toe. I decided that to determine its fitness, it would play against a "dumb" AI, placing O's in random locations on the grid, and gaining fitness based on whether or not it placed X's in a valid location (losing fitness if it placed an X on top of another X or an O), and gaining a lot of fitness if it won against the "dumb" AI. This would work, but when a network got really lucky and the "dumb" AI placed O's in impractical locations, the network would win and gain a lot of fitness, making it very difficult for another network to beat that fitness. Therefore, the learning process did not work and I was not able to generate a Tic Tac Toe network that actually worked well.
  
  I do not want the GA to learn based off an "intelligent" tic tac toe AI because the whole point of me training this GA is so that I do not have to make the AI in the first place. I want it to be able to learn rules on its own without me having to hard code an AI to be very good at it.
  
  So, I got to thinking, and I thought it would be interesting if the fitness of a network could be determined based off how well it played against OTHER NETWORKS in its generation. This does seem similar to how humans learn to play games, as I learned to play chess by playing against other people hundreds of times, learning from my mistakes, and my friends also increased in their ability to play chess as well. If GA's were to do that, that would mean I don't have to program AI to play the game (in fact, I wouldn't have to program a "dumb" AI as well, I would only have to hard code the rules of the game, obviously).
  
  My questions are:
  
  1. Has there been any research or results from GA's determining their fitness based off competing against each other? I did some searching but I have no idea what to look for in the first place (searching 'NEAT fight against each other' did not work well :-( )
  2. Does this method of training a GA seem practical? It seems practical to me, but are there any potential drawbacks to this? Are GA's meant to only calculate predetermined functions that exist, or do they have the potential to learn and do some decision making?
  3. If I were to do this, how would fitness be determined? Say, for the tic tac toe example, should fitness be determined based on whether or not a network places its X's or O's in viable locations, and add fitness if it wins and subtracts fitness if it loses? What about tying the game?
  4. Should networks of the same species compete against each other? If they did, then it would seem impractical to have species in the first place, as networks in the same species competing against each other would not allow a successful species to rise to the top, as it would be fighting against each other.
  5. Kind of out of topic, but with my original idea for the tic tac toe GA, would there be a better way to determine fitness? Would creating an intelligent AI be the best way to train a GA?
  
  Thanks for your time, as this is somewhat lengthy, and for your feedback!
  
  **Tags:** neural-networks, machine-learning, genetic-algorithms
  > **Comments:**
  > **username_1**: What you're describing is a type of what's known as a coevolutionary algorithm. Googling that should be a useful exercise.  I'd also point out that the general idea of playing against versions of yourself has a long history in the literature around learning to play games. One of the very earliest real success stories in AI was Arthur Samuel's checkers program in 1959. He trained a program to play the game at the level of a very strong human by having it play games against itself, each time improving itself via a mechanism that resembles what we would today call reinforcement learning.  
  > **username_2**: Let's have it clear...try to make your question brief and kept in mind that every one understands it .fast  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_5 on 2017-06-20. Score: 6 | Accepted answer
  
  i'm the main developer of [Neataptic](https://github.com/wagenaartje/neataptic), a Javascript neuro-evolution library.
  
  1. Very effective! Realise that this is how real-life evolution happened as well: we kept on improving against other species, which forced them to improve as well.
  2. Very practical, *especially if you don't want to set up any 'rules'* like you say, it makes the genomes find out what the rules are themselves.
  3. Basically, you let each genome in the population play X games against other genomes, I advise you let each genome play against every other genome in the population. An example of scoring would be giving the genome `1` point for winning, and `0.25` or `0.5` for a tie. Each game should always have a result!
  4. I'm not sure about this one, as I haven't implemented speciation.
  
  I want to give you some examples that I have worked on:
  
  * [Agar.io AI](https://wagenaartje.github.io/neataptic/articles/agario/) (neuro-evolved neural agents) - basically, I let neural networks evolve to get the highest score they can in agar.io, by competing against each other! It worked better than I expected.
  * Currently i'm working on new project, a kind of 'cops and robbers' style game.
  
  > **Comments:**
  > **username_6**: Awesome answer!  (More links would be useful on the basic concepts, since I'm noticing a recent disconnect in that area due the growing accessibility of the methods.)  I favor this approach because I can use guided learning to give my automata some basic axioms, but let their intelligence be a factor of self evolution, which hopefully leads to axioms they themselves discover. :)  
  > **username_7**: I was going to post examples from Neataptic, but then I saw your answer sir, and I am not worthy :D Nice to e-meet you!  
  
  ---
  
  ### Answer by username_3 on 2017-06-20. Score: 2
  
  The general notion is that of 'Competitive Coevolution' and there are many (maybe hundreds) of academic papers that describe various alternatives.
  
  The excellent (and freely available) [Essentials of Metaheuristics](https://cs.gmu.edu/~sean/book/metaheuristics/) has a whole chapter on the subject.
  
  
  ---
  
  ### Answer by username_4 on 2019-01-30. Score: 0
  
  Look up tournament selection
  Tournament selection is a method of selecting an individual from a population of individuals in a genetic algorithm.[1] Tournament selection involves running several "tournaments" among a few individuals (or "chromosomes") chosen at random from the population. The winner of each tournament (the one with the best fitness) is selected for crossover. Selection pressure, a probabilistic measure of a chromosome's likelihood of participation in the tournament based on the participant selection pool size, is easily adjusted by changing the tournament size[why?]. If the tournament size is larger, weak individuals have a smaller chance to be selected, because, if a weak individual is selected to be in a tournament, there is a higher probability that a stronger individual is also in that tournament.
  
  
  ---
  
  