package myagent.featuredetectors;

import edu.memphis.ccrg.lida.pam.tasks.BasicDetectionAlgorithm;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Luiz Fernando Romanini
 */
public class WhiteFeatureDetector extends BasicDetectionAlgorithm
{
	/*
	* Size of the shape in pixels.
	*/
	private int soughtArea = 10000;

	/*
	* The white background color should be counted!
	*/
	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 ] == 0xFFFFFFFF )
				++area;
		}

		if ( area == layer.length )
			return 1;

		return 0;
	}
}
