package org;

import org.config.Configuration;
import org.config.LoadProperties;
import org.factories.factoryExperiment;

public class Experiment{

	public static void main(String[] args) {
		LoadProperties lp = new LoadProperties(args,null);
		Configuration.setConfiguration(lp);
		
		factoryExperiment.createExperiment().run();
	}	
 
	// TODO: This method shall:
	//			- Accept as input a topology/individual from a GA
	//          - Return the total size of the avalanches in a run of the sandpile
	public static long totalavalanches(String[] args) {
		LoadProperties lp = new LoadProperties(args,null);
		Configuration.setConfiguration(lp);
		
		Configuration.verbosity=0;
		Sandpile sand = factoryExperiment.createExperiment();
		sand.run();
		return sand.getTotalSizeOfAvalanches();
	}	
	
	
	/**
	 * This method accepts
	 * @param args the arguments from the command line with potential properties
	 * @param graph It's the topology for the CA. Intended for individuals of a GA 
	 * @return the total size of the avalanches in a run of the sandpile
	 */
	public static long avalanchesFromGraph(String[] args,boolean [][]graph) {
			LoadProperties lp = new LoadProperties(args,null);
			Configuration.setConfiguration(lp);
			
			Configuration.verbosity=0;
			Sandpile sand = factoryExperiment.createExperimentFromGraph(graph);
			sand.run();
			return sand.getTotalSizeOfAvalanches();
		}	
}
