package at.oefai.aaa.agent.jam;

import at.oefai.aaa.agent.jam.types.Binding;

/**
 * A built-in JAM primitive action for binding and matching plan variables with world model entries.
 * @author Marc Huber
 * @author Jaeho Lee
 */
class FactAction extends WorldModelAction {

    /** Constructor w/ relation to check against the World Model as an argument in addition to the interpreter. */
    FactAction(final Relation pRelation, final WorldModelTable pWorldModel) {
        super(pRelation, pWorldModel);
    }


    // Member functions

    public boolean isExecutableAction() { return true; }

    /** Check the relation against the World Model. */
    public Result execute(final Binding b, final Goal currentGoal) {
        return this.worldModel.match(this.relation, b) ? Result.SUCCEEDED : Result.FAILED;
    }

    /** Output information to the stream in an in-line manner. */
    public String formattedString(final Binding b) {
        return "FACT " + this.relation.formattedString(b) + "; ";
    }

}



