public void paint(Graphics g){
    if( environment != null && ((Labyrinth)environment).structure != null ){
      Labyrinth   env = (Labyrinth)environment;
      int n = env.structure.length;
      int m = env.structure[0].length;
      g.setColor( Color.lightGray );
      int GRID_SIZE = CELL_SIZE * DIMENSION;
      for (int i = 0; i <= n; i++) {
        int j = getCanvasValue( i );
        g.drawLine( j, GRID_SIZE + MARGIN, j, MARGIN );
        g.drawLine( GRID_SIZE + MARGIN, j, MARGIN, j );
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          g.setColor( Color.blue );
          LabyrinthPercept p = env.getPercept(i,j);
          int x = getCanvasValue(i);
          int y = getCanvasValue(j);
          p.draw( g, x, y, CELL_SIZE, env.language );
        }
      }

      SimulatedAgent agent = (SimulatedAgent)this.environment.getAgent();
//      System.out.println( "The agent program is : " + agent.getProgram().getClass().getCanonicalName() );
      int direction = ( (Integer) agent.getAttribute(env.D)).intValue();
      int x = ( (Integer) agent.getAttribute(env.X)).intValue();
      int y = ( (Integer) agent.getAttribute(env.Y)).intValue();
      g.setColor( Color.red );
      int X = getCanvasValue( x );
      int Y = getCanvasValue( y );
      int EYE_SIZE = 6;
      g.drawOval( X + EYE_SIZE/2, Y + EYE_SIZE/2, CELL_SIZE - EYE_SIZE, CELL_SIZE - EYE_SIZE );
      switch( direction ){
        case 0: g.drawOval( X + CELL_SIZE/2 - EYE_SIZE/2, Y , EYE_SIZE, EYE_SIZE); break;
        case 1: g.drawOval( X +  CELL_SIZE - EYE_SIZE, Y + CELL_SIZE/2 - EYE_SIZE/2, EYE_SIZE, EYE_SIZE); break;
        case 2: g.drawOval( X + CELL_SIZE/2 - EYE_SIZE/2, Y + CELL_SIZE - EYE_SIZE, EYE_SIZE, EYE_SIZE); break;
        case 3: g.drawOval( X, Y + CELL_SIZE/2 - EYE_SIZE/2, EYE_SIZE, EYE_SIZE); break;
      }

    }

  }