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.awt.geom.Point2D;
011    import java.util.Random;
012    
013    /**
014     * Entity non-moving and not dangerous, used to test the reactions of the Agent.
015     * @author Benoit
016     * 
017     */
018    public class Food extends Entity {
019    
020    
021            /**
022             * Link to the Arena where the agent is placed.
023             */
024            protected Arena arena;
025    
026            public Food(Random gen, Arena a) {
027                    super();
028                    arena = a;
029                    generator = gen;
030                    size = 10;
031                    boolean isInsideArena;
032                    do {
033                            double x = (double) gen.nextInt(a.getSize()) - a.getShift();
034                            double y = (double) gen.nextInt(a.getSize()) - a.getShift();
035                            coord = new Point2D.Double(x, y);
036                            isInsideArena = a.isInside(x, y, (double) size);
037                    } while (!isInsideArena);
038    
039                    color_int = Color.GREEN;
040                    setName("F");
041    
042            }
043    
044    
045    
046            /**
047             * Returns the value of the Dangerous flag for the food (<code>false</code>).
048             * @see Entity#isDangerous()
049             */
050            public boolean isDangerous() {
051                    return false;
052            }
053    
054    
055    
056            /** 
057             * The food is not moving.
058             * @see Entity#isMoving()
059             */
060            public boolean isMoving() {
061                    return false;
062            }
063    
064    
065    
066            /**
067             * Food does not move.
068             * @see Entity#move(Arena, Entity[], int, java.awt.Graphics2D)
069             */
070            public void move(Arena a, Entity[] others, int nbagents, Graphics2D g) {        
071            }
072    
073    }