package at.oefai.aaa.agent.jam;

import java.io.Serializable;

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

/**
 * A built-in JAM primitive action for removing entries from the JAM world model.
 * @author Marc Huber
 * @author Jaeho Lee
 */

class RetractAction extends WorldModelAction implements Serializable {

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


    // Member functions

    public boolean isExecutableAction() { return true; }


    /** Retract the relation from the World Model. */
    public Result execute(final Binding b, final Goal currentGoal) {
        this.worldModel.retractRelation(this.relation, b);
        return Result.SUCCEEDED;
    }


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

}

