Package frsf.cidisi.exercise.arqueologic.situationCalculus

Source Code of frsf.cidisi.exercise.arqueologic.situationCalculus.ArqueologicAgent

package frsf.cidisi.exercise.arqueologic.situationCalculus;

import frsf.cidisi.faia.agent.Action;
import frsf.cidisi.faia.agent.NoAction;
import frsf.cidisi.faia.agent.Perception;
import frsf.cidisi.faia.agent.situationcalculus.SituationCalculusBasedAgent;
import frsf.cidisi.faia.exceptions.PrologConnectorException;
import frsf.cidisi.faia.solver.situationcalculus.SituationCalculus;

public class ArqueologicAgent extends SituationCalculusBasedAgent {

    private Action lastAction = NoAction.getInstance();

    public ArqueologicAgent() throws PrologConnectorException {
        this.setAgentState(new ArqueologicState());
    }

    @Override
    public void tell(Action action) {
        ArqueologicState kb = this.getAgentState();
        kb.tell(action);
    }

    @Override
    public void see(Perception p) {
        this.getAgentState().updateState(p);
    }

    @Override
    public Action selectAction() {
        this.setSolver(new SituationCalculus());

        Action selectedAction = null;
        try {
            selectedAction = this.getSolver().solve(new Object[]{this.getAgentState()});
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        this.lastAction = selectedAction;

        return selectedAction;
    }

    @Override
    public ArqueologicState getAgentState() {
        ArqueologicState agentState = (ArqueologicState) super.getAgentState();

        return agentState;
    }

    public Action getLastAction() {
        return this.lastAction;
    }
}
TOP

Related Classes of frsf.cidisi.exercise.arqueologic.situationCalculus.ArqueologicAgent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.