public void initTraining(){
    //by Budhitama Subagdja
    int previdx = 0; 
    int diffidx = 0;
    int maxseqlimit = SEQLENGTH;
    
    if(events.isEmpty()){
        System.out.println("ERROR: EMPTY EVENT SET!!");
        return;
    }
    int seqcount=0;
    int curSeqLen=0;
    seqStartIndexes = new ArrayList();
    seqLenIndexes = new ArrayList();
    seqStartIndexes.add(0);
    for(int i=0;i<events.size();i++){
        Event e=events.get(i);
        int winCode=episodic.newEventWinner(e.toArray());
        
        if(winCode==supportEvents.size()){
            supportEvents.add(new Vector<Integer>(0));
            supportEvents.get(winCode).add(new Integer(i));
        }
        else if(winCode<supportEvents.size()){
            supportEvents.get(winCode).add(new Integer(i));
        }
        else{
            System.out.println("Pls reconsider the logic!!!!!!!!!");
        }
        
        curSeqLen++;

        if((e.isForcedTer(e))||(episodic.seqLearner.tho<=0.0)){
             if(episodic.seqLearner.tho<=0.0)
                System.out.println("REACHING SEQUENCE LIMIT");
             else
                 System.out.println("TERMINATION SIGNAL DETECTED");
             curSeqLen=0;
             seqcount++;
             seqStartIndexes.add(i+1);
             diffidx = (i+1)-previdx;
             seqLenIndexes.add(diffidx);
             System.out.println("Episode length: " + diffidx);
             previdx = i+1;
             System.out.println("Last index: " + (i+1));
             System.out.println("End sequence: " + seqcount);
             System.out.println("F2: " + episodic.seqLearner.sequenceEndWinner());
             episodic.seqLearner.resetCurSeq();
             episodic.seqLearner.resetActivityF1();
             episodic.seqLearner.resetBaseLineTho();

        }
    }
    if(curSeqLen>0){
        seqcount++;
        System.out.println("End sequence: " + seqcount);
        System.out.println("F2: " + episodic.seqLearner.sequenceEndWinner());
        episodic.seqLearner.resetCurSeq();
        episodic.seqLearner.resetActivityF1();
        episodic.seqLearner.resetBaseLineTho();
    }
    
    evaluateKeys();
}