package de.dhbwstuttgart.strucTypes5.solve;

import de.dhbwstuttgart.strucTypes5.ausgabe.Help;
import de.dhbwstuttgart.strucTypes5.constraints.ConstraintAbstract;
import de.dhbwstuttgart.strucTypes5.constraints.ConstraintInterface;
import de.dhbwstuttgart.strucTypes5.constraints.ConstraintSubstitution;

import java.util.List;

/**
 * Created by sebastian on 03.05.17.
 */
public class Ruler {


    List<ConstraintInterface> constraintInterfaceList;
    List<ConstraintSubstitution> substitutionList;
    List<ConstraintAbstract> constraintList;


    public Ruler(List<ConstraintInterface> constraintInterfaceList, List<ConstraintSubstitution> substitutionList, List<ConstraintAbstract> constraintList) {
        this.constraintInterfaceList = constraintInterfaceList;
        this.substitutionList = substitutionList;
        this.constraintList = constraintList;
    }

    // gibt nur die Substitionen zurück
    private List<ConstraintSubstitution> ruleAll(List<ConstraintAbstract> constraints, List<ConstraintSubstitution> substitutions) {

        Rules rules = new Rules();
        rules.setConstraintInterfaces(constraintInterfaceList);
        rules.setSubstitutions(substitutions);

        rules.reduceEqual(constraints);
        rules.adapt2(constraints);
        rules.adapt1(constraints);
        rules.erase1(constraints);
        rules.erase2(constraints);
        rules.swap(constraints);
        rules.subst(constraints);
        rules.reflect(constraints);
        return rules.getSubstitutions();
    }


    public void  rule() {
        //System.out.println("StartConstraints: "  + constraintList);
        Help.print("StartConstraints" , constraintList);
       substitutionList =  ruleAll(constraintList,substitutionList);
        Help.print("Aktuelle Substitutionen: " ,substitutionList);
        Help.print("Aktuelle Constriants: " , constraintList);

        /*
        for (int i = 0 ; i <  10 ; i++) {
            Rules r = new Rules();
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.erase2(constraintList);
            r.reflect(constraintList);
            r.reflect(constraintList);
            r.reflect(constraintList);
        }
        */

    }





}
