001    /*
002     * SimuCS - Simulator to use with Classifier Systems 
003     * MSc project - Oxford University 
004     * by Benoit Isaac - Summer 2005
005     */
006    
007    package simuLCS;
008    import java.awt.Color;
009    import java.awt.Graphics2D;
010    import java.util.Random;
011    
012    /**
013     * Agent moving according to the position of the mouse.
014     * To move the Agent, the user has to drag the cursor inside the Arena
015     * @author Benoit
016     * 
017     */
018    public class AgentInteractive extends Agent {
019            
020            Utils utils ;
021            
022            public AgentInteractive(Utils u, Random gen, Arena a) 
023            {
024                            super(gen,a);
025                            this.setName("Robot");
026                            utils = u ;
027                            this.setColor_int(Color.RED);
028                            this.setSize(25);
029            }
030            
031            /**
032             * Moves according to the position of the cursor
033             */
034            public void move() 
035            {
036                    double x = (double) (utils.mouseGetX() - getArena().getShift());
037                    double y = (double) (utils.mouseGetY() - getArena().getShift());
038                    coord.setLocation(x,y);
039            }
040            
041            public void move(Arena a, Agent[] ag, int nbAgents, Graphics2D g)
042            {
043                    move();
044            }
045            
046    //      public void paint(Graphics2D g)
047    //      {
048    //              super.paint(g);
049    //              Point2D closPtArena = arena.closestPointTo(getCoord());
050    //              g.fillOval((int) closPtArena.getX(),(int) closPtArena.getY(), 4,4);
051    //      }
052    
053            
054            /**
055             * The agent Interactive is Dangerous (sheepdog)
056             */
057            public boolean isDangerous(){
058                    return true;
059            }
060    
061    
062    }