Package megamek.client.bot.ga

Examples of megamek.client.bot.ga.Chromosome


        }
    }

    // now they have a hard-coded hoard metality
    protected double getFitness(int iChromIndex) {
        Chromosome chrom = this.chromosomes[iChromIndex];
        ArrayList<MoveOption> possible = new ArrayList<MoveOption>();
        for (int iGene = 0; iGene < chromosomeDim; iGene++) {
            possible.add(new MoveOption(
                    this.moves.get(iGene)[chrom.genes[iGene]]));
        }
View Full Code Here


        }
        return -result + (max - distance_mod);
    }

    public MoveOption getResult() {
        Chromosome r = this.chromosomes[best];
        ArrayList<MoveOption> possible = new ArrayList<MoveOption>();
        for (int iGene = 0; iGene < chromosomeDim; iGene++) {
            possible.add(new MoveOption(this.moves.get(iGene)[r.genes[iGene]]));
        }
        Object[] move_array = possible.toArray();
View Full Code Here

        }
        return result;
    }

    protected void doRandomMutation(int iChromIndex) {
        Chromosome c1 = this.chromosomes[iChromIndex];
        // I don't think we need to mutate an empty chromosome
        if (c1.genes.length < 1) {
            return;
        }
        int r1 = (c1.genes.length > 2) ? Compute.randomInt(c1.genes.length - 1)
View Full Code Here

    public double[] getDamageUtilities() {
        int iChromIndex = populationDim - 1;
        targets.clear(); // could use ArrayList and not hashtable
        double[] result = new double[target_array.size()];
        Chromosome chromArrayList = chromosomes[iChromIndex];
        // TODO should account for high heat?
        int heat_total = 0;
        if (chromArrayList.genes[chromosomeDim - 1] >= target_array.size()) {
            chromArrayList.genes[chromosomeDim - 1] = valid_target_indexes.get(
                    0).intValue();
View Full Code Here

     * but the highest chance of mutation, this is where we use the primary
     * target heuristic to drive convergence
     */
    @Override
    protected void doRandomMutation(int iChromIndex) {
        Chromosome c1 = chromosomes[iChromIndex];
        // skip if it's an empty chromosome
        if (c1.genes.length < 1) {
            return;
        }
        int r1 = (c1.genes.length > 2) ? Compute.randomInt(c1.genes.length - 1)
View Full Code Here

        // use first weapon target as primary, not smart but good enough...
        AttackOption a = attack.get(0).get(0);
        (chromosomes[0]).genes[chromosomeDim - 1] = a.target.enemy_num;

        for (int i = 1; i < populationDim; i++) {
            Chromosome cv = chromosomes[i];
            for (int iGene = 0; iGene < chromosomeDim - 1; iGene++) {
                cv.genes[iGene] = Compute.randomInt(attack.get(iGene).size());
                if (i <= attack.size()) {
                    if (iGene + 1 == i) {
                        cv.genes[iGene] = 0; // fire
View Full Code Here

TOP

Related Classes of megamek.client.bot.ga.Chromosome

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.