Distributed, Adaptive Resource Allocation for Sensor Networks