
package myagent.featuredetectors;
import java.util.HashMap;
import java.util.Map;

import edu.memphis.ccrg.lida.pam.tasks.BasicDetectionAlgorithm;

/**
 * Shape detector
 * @author Javier Snaider
 * @author Ryan McCall
 */
public class EmptyFeatureDetector extends BasicDetectionAlgorithm {
    public static final int TOLERANCE = 5;
    private int soughtArea = 1000;
    private int backgroundColor = 0xFFFFFFFF;
    private Map<String, Object> smParams = new HashMap<String, Object>();
    @Override
    public void init() {
       super.init();
       smParams.put("mode","all");

       soughtArea = (Integer) getParam("area", 1000);
       backgroundColor = (Integer) getParam("backgroundColor", 0xFFFFFFFF);
    }
    @Override
    public double detect() {
        int[] layer = (int[]) sensoryMemory.getSensoryContent("visual",smParams);
        int area=0;
        for(int i=0;i<layer.length;i++){
            if(layer[i]!=backgroundColor){
                area++;
            }
        }
        if(area <= 0) return 1.0;
        return 0.0;
    }
}
