public int evaluate(World world)
        {
            //double accumulatedDistance = 0.0d;
            double lowestDistance = double.PositiveInfinity;
            int hitBonus = 0;

            for (int n = 0; n < 100; n++)
            {
                world.update();

                double distance = Distance.Calculate(world.missile, world.ship);

                if (distance < world.missile.velocity) distance = Distance.CalculateMinInLastLeg(world.missile, world.ship);

                if (distance < lowestDistance) lowestDistance = distance;

                //accumulatedDistance += distance;
                if (distance < 5.0d)
                {
                    hitBonus = 1000;
                    return hitBonus;
                }
            }

            return 250 - (int)lowestDistance;
            //return hitBonus - (int)accumulatedDistance;
        }
Exemplo n.º 2
0
        internal void draw(MissileProgram bestProgram)
        {
            world = new World(bestProgram);

            drawing.WaitOne();

            if (TERMINATE) return;

            drawing.Reset();

            this.Invoke(drawDelegate);
        }
        public int evaluate(GeneString genestring)
        {
            int total = 0;
            for (int n = 0; n < 100; n++)
            {
                World world = new World(new MissileProgramSemantics().parse(genestring));

                total += evaluate(world);
            }

            int lengthWeight = (int)Math.Pow(1.006d, genestring.getGenes().Length);
            lengthWeight /= 10;

            return total - lengthWeight;
        }
Exemplo n.º 4
0
        private void runCallback(MissileProgram program)
        {
            this.program = program;

            world = new World(program);
            draw100();

            btn_Generate.Enabled = true;
            btn_Run.Enabled = true;
        }
Exemplo n.º 5
0
        private void btn_StartOver_Click(object sender, EventArgs e)
        {
            updateTimer.Enabled = false;

            world = new World(program);

            drawWorld();
        }