Examples of PolytrisWholeAgent


Examples of eas.users.demos.polytris.agents.PolytrisWholeAgent

    private boolean addPolytrisAgent(
            ArrayList<Vector2D> relativePositions,
            Vector2D position,
            String agentType) {
        PolytrisWholeAgent wholeAgent = new PolytrisWholeAgent(null);
        Color agentColor = new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
        HashSet<Integer> successfullyAddedAgents = new HashSet<Integer>();
        for (Vector2D v : relativePositions) {
            if (v == null) {
                return false;
            }
        }

        if (agentType.equals("dynamite")) {
            if (rand.nextBoolean() && rand.nextBoolean()) {
                this.showText = "Heavy dynamite!";
                this.dynamiteStrength = 2;
            } else {
                this.showText = "Dynamite!";
                this.dynamiteStrength = 1;
            }
            this.dynamiteAgent = new HashSet<DynamiteAgent>();
        }
       
        if (agentType.equals("fuse")) {
            this.showText = "Ignate!";
            this.fuseAgent = new HashSet<FuseAgent>();
        }
       
        for (Vector2D v : relativePositions) {
            PacmanAgent2D agent;
            if (agentType.equals("dynamite")) {
                DynamiteAgent da = new DynamiteAgent(0, this, this.getParCollection());
                this.dynamiteAgent.add(da);
                agent = da;
                this.nextAgentType = "fuse";
            } else if (agentType.equals("fuse")) {
                FuseAgent fa = new FuseAgent(0, this, this.getParCollection());
                this.fuseAgent.add(fa);
                agent = fa;
                this.nextAgentType = "normal";
            } else {
                agent = new PacmanAgent2D(0, this, this.getParCollection(), agentColor);
            }
           
            agent.addSensor(new GenericSensor<Long, PolytrisEnvironment, PacmanAgent2D>() {
                /**
                 *
                 */
                private static final long serialVersionUID = -1927354872920066113L;

                @Override
                public Long sense(PolytrisEnvironment env,
                        PacmanAgent2D agent) {
                    return env.score;
                }

                @Override
                public String id() {
                    return "YOUR SCORE";
                }
            });

            agent.addSensor(new GenericSensor<Long, PolytrisEnvironment, PacmanAgent2D>() {

                /**
                 *
                 */
                private static final long serialVersionUID = -219056252893169910L;

                @Override
                public Long sense(PolytrisEnvironment env,
                        PacmanAgent2D agent) {
                    return -1l;
                }

                private ArrayList<Vector2D> nextSensingAgent = null;
                private VectorVersionOfAgent currentAgent;
               
                @Override
                public BufferedImage getSensorView(
                        PolytrisEnvironment env, PacmanAgent2D agent) {
                    try {
                        if (this.nextSensingAgent != PolytrisEnvironment.this.nextAgent) {
                            currentAgent = new VectorVersionOfAgent(
                                    PolytrisEnvironment.this.nextAgent,
                                    PolytrisEnvironment.this.getParCollection());
                            this.nextSensingAgent = PolytrisEnvironment.this.nextAgent;
                        }
                        return currentAgent.generateImage();
                               
                    } catch (Exception e) {
                        return new BufferedImage(50, 50, BufferedImage.TYPE_3BYTE_BGR);
                    }
                }
               
                @Override
                public String id() {
                    return "Next agent";
                }
            });
           
            wholeAgent.addPartAgent(agent);
            Vector2D pos = new Vector2D(position);
            pos.translate(v);
           
            float angle;
            if (!agentType.equals("normal")) {
View Full Code Here

Examples of eas.users.demos.polytris.agents.PolytrisWholeAgent

       
        return true;
    }

    private Vector2D getMiddle(int wholeAgentID) {
        PolytrisWholeAgent agent = this.agents.get(wholeAgentID);
        return this.getAgentPosition(agent.getAgents().get(0).id());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.