package math;

import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Term;

public class distance extends DefaultInternalAction {

    @Override
    public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
		Double Xini = Double.parseDouble(args[0].toString());
		Double Yini = Double.parseDouble(args[1].toString());
		Double Xdest = Double.parseDouble(args[2].toString());
		Double Ydest = Double.parseDouble(args[3].toString());
		double distX = Math.abs(Xini-Xdest);
		double distY = Math.abs(Yini-Ydest);

		boolean result1 = un.unifies(args[4], new NumberTermImpl(distX));
		boolean result2 = un.unifies(args[5], new NumberTermImpl(distY));
		
        return (result1 && result2);
    }
}

