Saturday, September 22, 2012

The Winner Takes it All

Another fitness function.

Before explaining the fitness function, i have to describe how fitness is measured. All robots of a population have to play a fixed amount of games against a reference robot. The number of wins, undecided game and losses is counted for every robot. Depending on these parameters a fitness value for each robot is calculated. This post describes the strategy for calculating the fitness value.

The strategy used favors won games to undecided ones. An example: If you win e.g 5 games of 10 and loose the other 5 games you get a better fitness value, than winning 4 games with 6 undecided games.

For the case of loosing all games, which i normal at the beginning of a breeding session, the length of the game i also considered. A robot that stays longer on the field is denoted fitter than one that is pushed out quickly.

The function in scala:

 
  def fitness(result: TestResult): Double = {
    def downSizeFactor = 1.0 / result.count.toDouble
    def winContingent = result.relWinCount
    def lossContingent = (1.0 - result.relLossCount * 0.99) * downSizeFactor
    def durationContingent = if (result.relWinCount > 0.00000000001) winDurationContingent else noWinDurationContingent
    def winDurationContingent = (1.0 - result.relDurationMeanOnWin * 0.99) * downSizeFactor * downSizeFactor
    def noWinDurationContingent = (result.relDurationMeanOnLoss * 0.99) * downSizeFactor * downSizeFactor
    100.0 / (winContingent + lossContingent + durationContingent) / result.count.toDouble
  }

I have also prepared some Diagrams to show the behavior of the functions.


This diagram shows the dependency of the fitness from the number of won games. The more games are won, the lower is the fitness (what is interpreted as a good fitness)


This diagram show that the fitness value does almost not depend on the number of losses. Except in top-left diagram, that shows the situation of no won match. In that diagram you can also see that the duration of the match has some (little) influence to the resulting fitness. Actually all diagrams contain five different colored lines that show the fitness depending on the mean relative length of the matches. But they are so close to each other, that a distinction is not possible.

No comments:

Post a Comment