Examples of PacmanAgent2D


Examples of eas.simulation.spatial.sim2D.standardAgents.PacmanAgent2D

            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")) {
                angle = 0;
            } else {
                angle = (float) ((rand.nextFloat() - 0.5) * 360);
            }
           
            if (!this.addCollidingAgent(agent, pos, angle)) {
                for (int i : successfullyAddedAgents) {
                    this.removeAgent(i);
                }
                return false;
            } else {
                successfullyAddedAgents.add(agent.id());
            }
           
            this.pacmanToTetrisAgentMapping.put(agent.id(), wholeAgent);
        }
       
        this.agents.put(agents.size(), wholeAgent);
        return true;
    }
View Full Code Here

Examples of eas.simulation.spatial.sim2D.standardAgents.PacmanAgent2D

        int y = this.getRealY(Math.round(pos.y));
       
        if (this.isCollidingAgent(agent.id())) {
            for (GridObject g : this.getFieldPosition(x, y)) {
                try {
                    PacmanAgent2D gridAgent = (PacmanAgent2D) g;
                    if (this.pacmanToTetrisAgentMapping.get(agent.id()) != this.pacmanToTetrisAgentMapping.get(gridAgent.id())) {
                        if (this.isCollidingAgent(gridAgent.id()) && gridAgent.id() != agent.id()) {
                            if (this.isRegularAgent(agent) || this.isRegularAgent(gridAgent)) {
                                return true;
                            }
                        }
                    }
View Full Code Here

Examples of eas.simulation.spatial.sim2D.standardAgents.PacmanAgent2D

       
        for (int j = lineNo; j >= 0; j--) {
            for (int i = 0; i < this.getGridWidth(); i++) {
                for (GridObject g : this.getFieldPosition(i, j)) {
                    try {
                        PacmanAgent2D pa = (PacmanAgent2D) g;
                        if (this.isRegularAgent(pa)
                                && (this.canRemoveCurrentActiveAgent || !this.agents.get(this.getCurrentAgentID()).getAgents().contains(pa))) {
                            this.removeAgent(pa.id());
                            numberOfBricks++;
                        }
                    } catch (Exception e) {System.out.println(false);}
                }
               
                for (GridObject g : this.getFieldPosition(i, j - 1)) {
                    try {
                        PacmanAgent2D pa = (PacmanAgent2D) g;
                        if (this.isRegularAgent(pa)
                                && (this.canRemoveCurrentActiveAgent || !this.agents.get(this.getCurrentAgentID()).getAgents().contains(pa))) {
                            this.setAgentPosition(pa.id(), new Vector2D(i, j));
                        }
                    } catch (Exception e) {System.out.println(false);}
                }
            }
        }
View Full Code Here

Examples of eas.simulation.spatial.sim2D.standardAgents.PacmanAgent2D

                (int) size.y + addHeight,
                new SimpleAcceleratingClock(15, 1000, 2),
                new HashSet<ArrayList<Vector2D>>());
       
        // Make all corners of field visualized.
        PacmanAgent2D pac0 = new PacmanAgent2D(0, env, params);
        env.addAgent(pac0, new Vector2D(0, 0), 0);
        env.setAgentPosition(0, new Vector2D(env.getGridWidth() - 1, env.getGridHeight() - 1));
        env.setAgentPosition(0, new Vector2D(0, env.getGridHeight() - 1));
        env.setAgentPosition(0, new Vector2D(env.getGridWidth() - 1, 0));
        env.removeAgent(0);
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.