package at.oefai.aaa.agent.jam;

import java.io.Serializable;

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

/**
 * Fact Predicate (a World Model Fact expression evaluable to true/false).
 * @author Marc Huber
 * @author Jaeho Lee
 */
class PredicateFact extends Predicate implements Serializable {

    private final WorldModelTable worldModel;

    /** Primary constructor. */
    PredicateFact(final String name, final Relation relation, final WorldModelTable pWorldModel) {
        super(name, relation);
        this.worldModel = pWorldModel;
    }

    // Member functions

    /** Calculate the truth value of the World Model relation. */
    public Value eval(final Binding binding) {
        if (this.worldModel.match(this.relation, binding)) {
            return Value.TRUE;
        }
        return Value.FALSE;
    }

}

