/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tileworld.agent;

import java.util.LinkedList;
import sim.app.woims.Vector2D;
import tileworld.environment.TWEnvironment;

/**
 *
 * @author Jakub
 */
public class Blackboard {
    
    Vector2D[] position;
    Class<?>[] mode;
    LinkedList[] fifo;
    boolean[] refueling;
    
    
    public Blackboard(TWEnvironment env) {
        
        position= new Vector2D[2];
        mode= new Class<?>[2];
        mode[0]=null; mode[1]=null;
        
        fifo=new LinkedList[2];
        fifo[0]=new LinkedList<TWAgentPercept>();
        fifo[1]=new LinkedList<TWAgentPercept>();
        
        refueling = new boolean[2];
        refueling[0]=false;
        refueling[1]=false;
        
    }
    
    public Vector2D getPosition(int myId){
        return position[1-myId];
    }
    
    public void setPosition(int myId,Vector2D pos){
        position[myId]=pos;
    }
    
    public void setMode(int myId,Class<?> m){
        mode[myId]=m;
    }
    
    public Class<?> getMode(int myId){
        return mode[1-myId];
    }
    
    public void uploadPercept(int myId,TWAgentPercept p){
        //System.out.println("Agent "+myId+" added a percept.");
        fifo[myId].add(p);
    }
    
    public LinkedList<TWAgentPercept> getPercepts (int myId){
       // System.out.println("Agent "+myId+" red a percept.");
        LinkedList<TWAgentPercept> o= fifo[1-myId];
        fifo[1-myId]=new LinkedList<TWAgentPercept>();
        return o;
    }
    
    public void updateRefueling(int myId, boolean state){
        refueling[myId]=state;
    }
    
    public boolean getRefueling(int myId){
        return refueling[1-myId];
    }
    
}
