/*
 * Net.java
 *
 * Created on 4 of August 2004, 22:21
 */
/**
 *
 * @author  Eng. Paulo Roque Silva
 */
import java.io.*;

public class Net implements Serializable {
    public static final long    serialVersionUID = 00032012L; // Data version
    static final int 	    ThresholdTaste  = 95;	   // Threshold percentage to fire neuron
    static final int 	    ThresholdSmell  = 90;	   // Threshold percentage to fire neuron
    static final int 	    ThresholdVision = 80;	   // Threshold percentage to fire neuron
    static final int 	    ThresholdTact   = 80;	   // Threshold percentage to fire neuron
    static final int 	    ThresholdSound  = 90;	   // Threshold percentage to fire neuron
    static final int 	    ThresholdProSelf= 80;	   // Threshold percentage to fire neuron
    static final int 	    ThresholdTime = 80;		   // Threshold percentage to fire neuron
//    static final int 	    ThresholdSenses = 80;	   // Threshold percentage to Senses && =80
    static final int 	    ThresholdAct  = 90;		   // Threshold percentage to fire neuron
    static final int 	    Habit		  = 10;		   // habit percentage to reduce? threshold
    int                     nTrails,                   // #Trails of the Net (#Senses + Proprioception)
    						nNeuronsPTaste,            // #Neurons of the Net (one Sense)
    						nNeuronsPSmell,            // #Neurons of the Net (one Sense)
    						nNeuronsPVision,           // #Neurons of the Net (one Sense)
    						nNeuronsPTact,             // #Neurons of the Net (one Sense)
    						nNeuronsPSound,            // #Neurons of the Net (one Sense)
    						nNeuronsPProSelf,          // #Neurons of the Net (one Sense)
    						nNeuronsT,                 // #Neurons of the Net Time
    						nActions,                  // #Action Neurons of the Net
    						actual,                    // actual step as equal as PlayLiberu.nStep
    						balance;                   // count steps as BALANCE
    Neuron		  			[]nodeTaste;               // net of Past id neurons
    Neuron		  			[]nodeSmell;               // net of Past id neurons
    Neuron		  			[]nodeVision;              // net of Past id neurons
    Neuron		  			[]nodeTact;                // net of Past id neurons
    Neuron		  			[]nodeSound;               // net of Past id neurons
    Neuron		  			[]nodeProSelf;             // net of Past id neurons
    Neuron		  			[][]time;                  // net of Past time neurons
    NeuronAct				[]actNode;                 // net of Cerebellum acting neurons

    /** Creates a new instance of Net */
    public Net(int nT, int nNPTaste, int nNPSmell, int nNPVision, int nNPTact, int nNPSound, int nNPProSelf,
    																						int nNT) {
        int t, n;    // indexes
	
        nTrails   = nT;
        nNeuronsPTaste = nNPTaste;
        nNeuronsPSmell = nNPSmell;
        nNeuronsPVision= nNPVision;
        nNeuronsPTact  = nNPTact;
        nNeuronsPSound = nNPSound;
        nNeuronsPProSelf=nNPProSelf;
        nNeuronsT = nNT;
        actual = 0;
        balance = 0;
        nodeTaste = new Neuron[nNeuronsPTaste];
        nodeSmell = new Neuron[nNeuronsPSmell];
        nodeVision= new Neuron[nNeuronsPVision];
        nodeTact  = new Neuron[nNeuronsPTact];
        nodeSound = new Neuron[nNeuronsPSound];
        nodeProSelf= new Neuron[nNeuronsPProSelf];
        for (n=0; n<nNeuronsPTaste; n++)
  		   nodeTaste[n] = new Neuron(n, ThresholdTaste);
        for (n=0; n<nNeuronsPSmell; n++)
  		   nodeSmell[n] = new Neuron(n, ThresholdSmell);
        for (n=0; n<nNeuronsPVision; n++)
  		   nodeVision[n] = new Neuron(n, ThresholdVision);
        for (n=0; n<nNeuronsPTact; n++)
  		   nodeTact[n] = new Neuron(n, ThresholdTact);
        for (n=0; n<nNeuronsPSound; n++)
  		   nodeSound[n] = new Neuron(n, ThresholdSound);
        for (n=0; n<nNeuronsPProSelf; n++)
  		   nodeProSelf[n] = new Neuron(n, ThresholdProSelf);
        time = new Neuron[nNeuronsT][nTrails];
	    for (t=0; t<nTrails; t++)
	           for (n=0; n<nNeuronsT; n++)
	        		   time[n][t] = new Neuron(n, ThresholdTime);
        actNode = new NeuronAct[nNeuronsPProSelf];
        for (n=0; n<nNeuronsPProSelf; n++) 
        	actNode[n] = new NeuronAct(n, ThresholdAct);
    }
    
    public int addDataActual() {
    	
    	actual += 1;
    	return actual;
    }
}
