@Override
	public int eval(Critter c) {
		// returns the value of this expression for Critter c
    	Random rand = new Random();
    	int index = expr.eval(c);
    	int value;
    	String sensor = op.toString();
    	if(sensor.equals("mem")){
    		if(index >= c.memlength)
    			return 0;
    		value = c.getMem(index);
    	} else if (sensor.equals("nearby")){
    		value = c.getSense(index);
    	} else if (sensor.equals("ahead")){
    		value = c.getAhead(index);
    	} else if (sensor.equals("random")){
    		value = rand.nextInt(index);
    		if(index < 2)
    			value = 0;
    	} else {
    		System.out.println("Error in UnaryExpr eval method");
    		value = 0;
    	}
    		
    	return value;
	}