Package eas.math.geometry

Examples of eas.math.geometry.Vector2D


        float force = 1500;
        this.color = Color.gray;
        if (this.id() == 1 && (
                e.getEventDescription().equals(ConstantsSimulation.KEY_EVENT_ARROW_KEY_ENCODING_RIGHT)
             || e.getEventDescription().equals(ConstantsSimulation.KEY_EVENT_ARROW_KEY_ENCODING_UP))) {
            Vector2D v = ((AbstractEnvironment2D) this.getEnvironment()).getNormalizedLOV(this.id());
            this.addForce(new Vector2f((float) v.x * force, (float) v.y * force));
            this.color = Color.orange;
            this.lastActionTime = lastActionTime.getLastTick();
            this.fuelWasted++;
        }
        if (this.id() == 2 && (
                e.getEventDescription().equals(ConstantsSimulation.KEY_EVENT_ARROW_KEY_ENCODING_LEFT)
                || e.getEventDescription().equals(ConstantsSimulation.KEY_EVENT_ARROW_KEY_ENCODING_UP))) {
            Vector2D v = ((AbstractEnvironment2D) this.getEnvironment()).getNormalizedLOV(this.id());
            this.addForce(new Vector2f((float) v.x * force, (float) v.y * force));
            this.color = Color.orange;
            this.lastActionTime = lastActionTime.getLastTick();
            this.fuelWasted++;
        }
View Full Code Here


        JasmineRobotWithoutMutationMatrixSelection agent;
        MARBBrain<AbstractAgent2D<?>> brain;
        Random rand = new Random(params.getSeed());
        String gutesGenom = "001, 003, 003, 001, 000, 012, 004, 196, 000, 015, 000, 012, 007, 135, 000, 006, 000, 010, 000, 000, 001, 001, 000, 012, 001, 191, 000, 004, 000, 012, 001, 032, 000, 005, 000, 012, 003, 073, 000, 015, 000, 011, 000, 012, 004, 170, 000, 016, 000, 010, 000, 010, 000, 000, 005, 001, 000, 012, 004, 000, 012, 007, 000, 015, 000, 012, 001, 073, 000, 008, 000, 011, 000, 000, 011, 001, 000, 000, 000, 015, 003, 003, 001, 000, 000, 000, 011, 004, 001, 001, 000, 012, 006, 031, 000, 008, 000, 000, 022, 001, 000, 000, 000, 026, 003, 005, 001, 000, 000, 000, 010, 002, 005, 001, 000, 000, 000, 009, 003, 004, 001, 000, 012, 006, 108, 000, 009, 000, 012, 004, 140, 000, 016, 000, 010, 000, 012, 006, 125, 000, 008, 000, 011, 000, 000, 010, 001, 000, 012, 001, 092, 000, 016, 000, 012, 003, 113, 000, 016, 000, 012, 001, 017, 000, 015, 000, 012, 003, 000, 012, 001, 000, 008, 000, 011, 000, 010, 000, 010, 000, 000, 006, 001, 000, 012, 001, 163, 000, 009, 000, 012, 003, 000, 012, 001, 000, 015, 000, 010, 000, 000, 015, 001, 000, 012, 002, 013, 000, 016, 000, 012, 005, 091, 000, 006, 000, 010, 000, 000, 011, 001, 000, 000, 000, 022, 004, 005, 001, 000, 012, 003, 140, 000, 009, 000, 012, 007, 098, 000, 009, 000, 010, 000, 012, 001, 071, 000, 008, 000, 012, 007, 210, 000, 008, 000, 011, 000, 010, 000, 000, 015, 001, 000, 000, 000, 006, 005, 003, 001, 000, 012, 006, 045, 000, 015, 000, 000, 011, 001, 000, 000, 000, 005, 005, 009, 001, 000, 012, 006, 158, 000, 015, 000, 012, 006, 132, 000, 009, 000, 012, 004, 080, 000, 009, 000, 012, 002, 000, 012, 005, 000, 016, 000, 010, 000, 011, 000, 011, 000, 000, 006, 001, 000, 012, 003, 247, 000, 008, 000, 012, 004, 089, 000, 008, 000, 011, 000, 000, 009, 001, 000, 012, 005, 253, 000, 016, 000, 000, 004, 001, 000, 012, 005, 095, 000, 009, 000, 012, 006, 045, 000, 009, 000, 010, 000, 000, 019, 001, 000, 012, 005, 081, 000, 015, 000, 012, 005, 213, 000, 009, 000, 010, 000, 000, 026, 001, 000, 012, 007, 000, 012, 005, 000, 015, 000, 000, 011, 001, 000, 000, 000, 004, 005, 003, 001, 000, 000, 000, 019, 005, 001, 001, 000, 012, 007, 000, 012, 002, 000, 015, 000, 000, 002, 001, 000, 000, 000, 002, 005, 004, 001, 000, 012, 006, 143, 000, 008, 000, 012, 007, 199, 000, 015, 000, 011, 000, 000, 002, 001, 000, 000, 000";
        String schlechtesGenom = "001, 003, 001, 001, 000, 013, 000, 000, 002, 001, 000, 000, 000, 002, 004, 001, 001, 000, 000, 000";
        Vector2D pos;
        double richt;
       
        if (numGoodAgents < 1) {
            numGoodAgents = 1;
        }
        if (numBadAgents < 1) {
            numBadAgents = 1;
        }
       
        Rectangle2D bound = new Rectangle2D(env.getBoundingBox(false));
       
        double puffer = 100;
        bound.setLeft(bound.upperLeftCorner().x + puffer);
        bound.setRight(bound.lowerRightCorner().x - puffer);
        bound.setTop(bound.upperLeftCorner().y + puffer);
        bound.setBottom(bound.lowerRightCorner().y - puffer);
       
        for (int j = 0; j < numGoodAgents; j++) {
            agent = new JasmineRobotWithoutMutationMatrixSelection(
                    j,
                    env,
                    rand,
                    params,
                    true,
                    360,
                    gutesGenom,
                    schlechtesGenom,
                    wkeitsMatrix);
            brain = new MARBBrain<AbstractAgent2D<?>>(
                    agent,
                    gutesGenom,
                    params);
            agent.implantBrain(brain);

            pos = new Vector2D(
                    rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
                    rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
            richt = rand.nextDouble() * 360;
           
            while (!env.addCollidingAgent(
                    agent,
                    pos, richt)) {
                pos = new Vector2D(
                        rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
                        rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
            }
           
        }

        for (int j = 0; j < numBadAgents; j++) {
            agent = new JasmineRobotWithoutMutationMatrixSelection(
                    j,
                    env,
                    rand,
                    params,
                    true,
                    360,
                    gutesGenom,
                    schlechtesGenom,
                    wkeitsMatrix);
            brain = new MARBBrain<AbstractAgent2D<?>>(
                    agent,
                    schlechtesGenom,
                    params);
            agent.implantBrain(brain);

            pos = new Vector2D(
                    rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
                    rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
            richt = rand.nextDouble() * 360;
           
            while (!env.addCollidingAgent(
                    agent,
                    pos, richt)) {
                pos = new Vector2D(
                        rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
                        rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
            }
           
        }
View Full Code Here

    }
   
    @Override
    public List<SingleParameter> getParameters() {
        List<SingleParameter> list = super.getParameters();
        list.add(new SingleParameter("NumberOfAgents", Datatypes.VECTOR2D, new Vector2D(20, 20), "Number of (good, bad) Agents.", this.id().toUpperCase()));
        list.add(new SingleParameter("SelectionNumberK", Datatypes.INTEGER, 4, "Anzahl selektierter Roboter für Turnier", this.id().toUpperCase()));
        list.add(new SingleParameter("ExponentWkeitsMatrix", Datatypes.DOUBLE, 0.0, "Exponent für die Wahrscheinlichkeit der Selektion von guten Agenten (negative Zahlen bewirken positiven Exponenten für Selektion von schlechten Agenten).", this.id().toUpperCase()));
        list.add(new SingleParameter("SonderMatrix?", Datatypes.BOOLEAN, false, "Ob die Matrix über einen Sonderalgorithmus erzeugt werden soll, der im Code begutachtet werden muss (ignoriert Exponent).", this.id().toUpperCase()));
        return list;
    }
View Full Code Here

    @Override
    public strictfp Polygon2D getAgentShape() {
        if (shape == null) {
            shape = new Polygon2D();
            shape.add(new Vector2D(-8, 0));
            shape.add(new Vector2D(8, 0));
            shape.add(new Vector2D(8, 2));
            shape.add(new Vector2D(-8, 2));
            shape.translateRootPointToMiddle();
        }

        return shape;
    }
View Full Code Here

            final double precision = 200;
            final double radius = rad;
            shape = new Polygon2D();
           
            for (double d = 0; d < Math.PI * 2; d += Math.PI * 2 / precision) {
                shape.add(new Vector2D(Math.sin(d) * radius, Math.cos(d) * radius));
            }
        }
       
        return shape;
    }
View Full Code Here

    @Override
    protected void fitness(Wink simTime) {
        // Fitness Entfernung.
        if (super.fitnessEntfernung) {
            if (simTime.getLastTick() % this.selectionInterval == this.selectionInterval - 1) {
                @SuppressWarnings("rawtypes")
                Vector2D currentPos = ((AbstractEnvironment2D) this
                        .getEnvironment()).getAgentPosition(this.id());
                if (super.lastPos == null) {
                    this.lastPos = new Vector2D(currentPos);
                }
                fitness = this.lastPos.distance(currentPos);
                this.lastPos = currentPos;
            }
        }
View Full Code Here

    }

    @Override
    public Vector2D getPointInVisualization(Vector3D fieldPos2) {
        Rectangle2D bdb = this.env.getBoundingBox(false);
        Vector2D envSizeTrans = new Vector2D(bdb.middle());
        envSizeTrans.div(-1);
       
        Vector2D fieldPos = new Vector2D(fieldPos2.x, fieldPos2.y);
        fieldPos.translate(envSizeTrans);
       
        Vector3D fieldPos3D = new Vector3D(
                (fieldPos.x) * 10 / (Math.abs(fieldPos.y) + 12),
                (fieldPos.y) * 10 / (Math.abs(fieldPos.x) + 12),
                0);
View Full Code Here

        return super.getPointInVisualization(fieldPos3D);
    }

    @Override
    public Vector2D getRealPosFromScreenPos(Vector2D screenPos) {
        Vector2D pos = super.getRealPosFromScreenPos(screenPos);

        Rectangle2D bdb = this.env.getBoundingBox(false);
        Vector2D envSizeTrans = new Vector2D(bdb.middle());
       
        /*
         * The "position inside a polygon" information might be calculated
         * slightly incorrect due to distortion of polygons. (TODO: fix that
         * in environment.)
         */
       
        Vector2D pos2 = new Vector2D(
                pos.x / 10 * (Math.abs(pos.y) + 12),
                pos.y / 10 * (Math.abs(pos.x) + 12));

        pos2.translate(envSizeTrans);
       
        return pos2;
    }
View Full Code Here

        return super.getPointInVisualization(fieldPos);
    }

    @Override
    public Vector2D getRealPosFromScreenPos(Vector2D screenPos) {
        Vector2D pos = super.getRealPosFromScreenPos(screenPos);

        /*
         * The "position inside a polygon" information might be calculated
         * slightly incorrect due to distortion of polygons. (TODO: fix that
         * in environment.)
         */
       
        Vector2D pos2 = new Vector2D(pos.x - Math.asin(pos.y), pos.y - Math.asin(pos.x));

        return pos2;
    }
View Full Code Here

        return super.getPointInVisualization(fieldPos);
    }

    @Override
    public Vector2D getRealPosFromScreenPos(Vector2D screenPos) {
        Vector2D pos = super.getRealPosFromScreenPos(screenPos);

        /*
         * The "position inside a polygon" information might be calculated
         * slightly incorrect due to distortion of polygons. (TODO: fix that
         * in environment.)
         */
       
        Vector2D pos2 = new Vector2D(pos.x - Math.asin(pos.y), pos.y - Math.asin(pos.x));

        return pos2;
    }
View Full Code Here

TOP

Related Classes of eas.math.geometry.Vector2D

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.