diff --git a/.classpath b/.classpath index e1c6d65..fe259db 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + + - diff --git a/.gitignore b/.gitignore index 43ffe60..ae3c172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - /bin/ -/png/ diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab1..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/hello.png b/hello.png deleted file mode 100644 index 1b90b2a..0000000 --- a/hello.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a6dd45349bc94101a70a274b8c1e51c873d96e11313609d6fedc347a1161d5c2 -size 17255 diff --git a/hello_lol.png b/hello_lol.png deleted file mode 100644 index ed7e023..0000000 --- a/hello_lol.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ce3ef0a7172958af3c54840321e8ad4dd107139288f1c9b2527aa3c3e70f4c10 -size 9725 diff --git a/src/neural/BattlefieldParameterEvaluator.java b/src/neural/BattlefieldParameterEvaluator.java index bd70ce1..d909b2e 100644 --- a/src/neural/BattlefieldParameterEvaluator.java +++ b/src/neural/BattlefieldParameterEvaluator.java @@ -21,7 +21,6 @@ import org.encog.neural.networks.training.propagation.resilient.ResilientPropaga import robocode.BattleResults; import robocode.control.*; import robocode.control.events.*; - import neural.Palette; public class BattlefieldParameterEvaluator { @@ -45,11 +44,15 @@ public class BattlefieldParameterEvaluator { final static double NN_TRAINING_ERROR = 0.001; // Maximum robot score obtained - used for scaling <0,1> final static int BATTLE_MAX_SCORE = 250; + /* The name of the palette. Must be one of "Spectrum", + * "PaleSpectrum", "Grayscale", "CyclicGrayscale", "CyclicRedCyan", + * "EarthSky", "HotCold", or "Fire". */ + final static String PALETTE = "PaleSpectrum"; static int NdxBattle; static double[] FinalScore1; static double[] FinalScore2; - + public static void main(String[] args) { double[] BattlefieldSize = new double[NUMSAMPLES]; double[] GunCoolingRate = new double[NUMSAMPLES]; @@ -75,7 +78,7 @@ public class BattlefieldParameterEvaluator { RobotSpecification[] competingRobots = engine.getLocalRepository("sample.RamFire,sample.TrackFire"); RobotSetup[] robotSetups = new RobotSetup[2]; for (NdxBattle = 0; NdxBattle < NUMSAMPLES; NdxBattle++) { - // Choose the battlefield size and gun cooling rate   + // Choose the battlefield size and gun cooling rate BattlefieldSize[NdxBattle] = rangedRand(rng, MINBATTLEFIELDSIZE, MAXBATTLEFIELDSIZE); GunCoolingRate[NdxBattle] = rangedRand(rng, MINGUNCOOLINGRATE, MAXGUNCOOLINGRATE); // BattlefieldSize[NdxBattle] = MAXBATTLEFIELDSIZE * (0.1 + 0.9 * rng.nextDouble()); @@ -99,12 +102,13 @@ public class BattlefieldParameterEvaluator { System.out.println(Arrays.toString(GunCoolingRate)); System.out.println(Arrays.toString(FinalScore1)); System.out.println(Arrays.toString(FinalScore2)); + // Create the training dataset for the neural network double[][] RawInputs = new double[NUMSAMPLES][NUM_NN_INPUTS]; double[][] RawOutputs = new double[NUMSAMPLES][1]; for (int NdxSample = 0; NdxSample < NUMSAMPLES; NdxSample++) { // IMPORTANT: normalize the inputs and the outputs to - // the interval [0,1]   + // the interval [0,1] RawInputs[NdxSample][0] = BattlefieldSize[NdxSample] / MAXBATTLEFIELDSIZE; RawInputs[NdxSample][1] = GunCoolingRate[NdxSample] / MAXGUNCOOLINGRATE; RawOutputs[NdxSample][0] = FinalScore1[NdxSample] / BATTLE_MAX_SCORE; @@ -112,7 +116,7 @@ public class BattlefieldParameterEvaluator { BasicMLDataSet MyDataSet = new BasicMLDataSet(RawInputs, RawOutputs); - // Create and train the neural network    + // Create and train the neural network BasicNetwork network = new BasicNetwork(); network.addLayer(new BasicLayer(null, true, NUM_NN_INPUTS)); network.addLayer(new BasicLayer(new ActivationSigmoid(), true, NUM_NN_HIDDEN_UNITS)); @@ -149,7 +153,9 @@ public class BattlefieldParameterEvaluator { } } - Palette palette = new Palette(); +// Palette palette = new Palette(); + Palette palette = Palette.makeDefaultPalette(PALETTE); + // Simulate the neural network with the test samples and fill a matrix for (int NdxBattleSize = 0; NdxBattleSize < NUMBATTLEFIELDSIZES; NdxBattleSize++) { @@ -186,7 +192,7 @@ public class BattlefieldParameterEvaluator { } BufferedImage img = new BufferedImage(NUMCOOLINGRATES, NUMBATTLEFIELDSIZES, BufferedImage.TYPE_INT_RGB); img.setRGB(0, 0, NUMCOOLINGRATES, NUMBATTLEFIELDSIZES, OutputRGBint, 0, NUMCOOLINGRATES); - File f = new File("hello.png"); + File f = new File("hello_" + PALETTE + ".png"); try { ImageIO.write(img, "png", f); } @@ -217,7 +223,7 @@ public class BattlefieldParameterEvaluator { static class BattleObserver extends BattleAdaptor { // Called when the battle is completed successfully with battle results public void onBattleCompleted(BattleCompletedEvent e) { - System.out.println("‐‐ Battle has completed ‐‐"); + System.out.println("Battle has completed."); // Get the indexed battle results BattleResults[] results = e.getIndexedResults(); // Print out the indexed results with the robot names