import java.util.*; |

protected int timeIndex; |

protected int timeIndex = 1; |

private Queue<Update> updateQueue = new LinkedList<Update>(); private Update nextUpdate = null; |

* @param weights - the nubmer of weights found in a node |

* @param weights - the number of weights found in a node |

// if(lattice[i] > maxLatticeDim?) { // maxLatticeDim? = lattice[i]; // } //end if |

//Initializes? each node randomly, not very well done |

//I have found that in a 2D map with equal dimensions //that if you set each weight outward from the center //at a distance of about a quarter, and then guassian //it from there with a .5 = dimension/4, that it works //alot better, but my code is far to complex and messy //to include here |

for(int i=0; i<nodes.length;i++) { |

for(int i=0; i<size();i++) { |

public int size() { return nodes.length; } public void addUpdate(double[] input, int index) { updateQueue.offer(new Update(input,index)); } public void distributeUpdate(int num) { if((nextUpdate == null || nextUpdate.startNode > size()) && !updateQueue.isEmpty()) { nextUpdate = updateQueue.poll(); bmu = getBMU(nextUpdate.weights); timeIndex++; } if(nextUpdate == null) return; for(int i=nextUpdate.startNode; i<size() && i < (nextUpdate.startNode + num); i++) { nodes[i].update(nextUpdate.weights, nextUpdate.index); nextUpdate.startNode++; } } |

for(int i=0; i<nodes.length; i++) { |

for(int i=0; i<size(); i++) { |

private class Update { public double[] weights; public int index; public int startNode; public Update(double w[], int i) { weights = w; index = i; startNode = 0; } } |

//Make? this smarter, it should degrade over time, and it determines //The? size of the area to update, it should be based on the physical //size of the map, not the number of nodes (easiest is the smallest dimension) //I find its best if it slowly decreases in size over about 100 to 1000 ticks/updates double variance = 10/map.timeIndex; |

double variance = Math.min(2,Math.log(.2*map.timeIndex+1)+.25); |

//double limiter = Math.max(Math.exp(-(map.timeIndex/1000)),.75); if(neighborhood < 0.001) return; |

//This? makes the whole thing ALOT faster. Remove for precision or if //you wanna test how you bot handles turn skipping. if(neighborhood < 0.0002) return; //Much? more can be done here, this should also be based on time //and it is, however if this is the bmu, then it will get changed //to the input, an undesirable thing later on. I never did this in //my prototype gun, I could of achieved greater precision here |

//This? is just the index updating, very important to multiply in the neighborhood //otherwise it gets very messy later on, not to much you can do here unlike other areas //.7 is purely a magic number I came up with, I find binIndexes / 30 works well too |

// statBin[i] = KTools.rollingAvg(bin[0][i], neighborhood*input, // Math.min(update_num, 5), 100); |

Yah, I realize I could do better for an example, but I really wanna see what everyone else can come up with for this, its a very basic SOM system, I have myself introduced my own distributed update and so on, this is just the data control. If you like I can add things into this, but I am not an expert programmer, and my methods are anything but pretty. --Chase-san |

Yah, I realize I could do better for an example, but I really wanna see what everyone else can come up with for this, its a very basic SOM system, I have myself introduced my own distributed update and so on, this is just the data control. If you like I can add things into this, but I am not an expert programmer, and my methods are anything but pretty. --Chase-san Its still not running 100% when I plug it into my old prototype gun, but mostly cause I think it uses much more well formed code. ;) --Chase-san |