I want to upgrade my evolution simulator to use Hebb learning, like this one. I basically want small creatures to be able to learn how to find food. I achieved that with the bas
You can try with my code.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelhebb;
/**
*
* @author Raka
*/
public class ModelHebb {
public static void main(String[] args) {
Integer xinput[][] = new Integer[][]{
{1, 1},
{1, -1},
{-1, 1},
{-1, -1}
};
Integer xtarget[] = new Integer[]{
1,
-1,
-1,
-1
};
Integer xweight[] = new Integer[xinput[0].length];
System.out.println("\t Iterasi \t");
Integer bayes = 0;
for (int i = 0; i < xtarget.length; i++) {
for (int j = 0; j < xinput[i].length; j++) {
int temp = xweight[j]==null?0:xweight[j];
xweight[j] = temp + (xinput[i][j] * xtarget[i]);
System.out.print("W"+j+": "+xweight[j]+"\t");
}
bayes = bayes + xtarget[i];
System.out.println("Bobot : " + bayes);
}
}
}