// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   BestSelMutation.java

package drm.genetics.advanced;

import drm.genetics.Individual;
import drm.genetics.simple.SimpleMutation;

public class BestSelMutation extends SimpleMutation
{

	protected int tries;

	public void setTries(int tries)
	{
		this.tries = tries;
	}

	public int getTries()
	{
		return tries;
	}

	public BestSelMutation()
	{
		tries = 2;
	}

	public BestSelMutation(double percentage)
	{
		super(percentage);
		tries = 2;
	}

	public BestSelMutation(double percentage, int tries)
	{
		super(percentage);
		this.tries = 2;
		setTries(tries);
	}

	public void mutateSame(Individual individ)
	{
		Individual ind1 = individ.copy();
		Individual ind2 = individ.copy();
		for(int i = 0; i < tries; i++)
		{
			super.mutateSame(ind1);
			if(ind2.compareTo(ind1) > 0)
				ind1 = ind2.copy();
			else
			if(ind1.compareTo(ind2) > 0)
				ind2 = ind1.copy();
		}

		individ.accessGenome(ind1.getGenome());
		individ.updateWeight();
	}
}
