|
|
|
@ -40,7 +40,7 @@ public class BattlefieldParameterEvaluator { |
|
|
|
|
// Number of epochs for training
|
|
|
|
|
final static int NUM_TRAINING_EPOCHS = 100000; |
|
|
|
|
// The requested error in nn training
|
|
|
|
|
final static double NN_TRAINING_ERROR = 0.01; |
|
|
|
|
final static double NN_TRAINING_ERROR = 0.001; |
|
|
|
|
// Maximum robot score obtained - used for scaling <0,1>
|
|
|
|
|
final static int BATTLE_MAX_SCORE = 250; |
|
|
|
|
|
|
|
|
@ -121,14 +121,15 @@ public class BattlefieldParameterEvaluator { |
|
|
|
|
System.out.println("Training network..."); |
|
|
|
|
final ResilientPropagation train = new ResilientPropagation(network, MyDataSet); |
|
|
|
|
|
|
|
|
|
// int epoch = 1;
|
|
|
|
|
int epoch = 1; |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
train.iteration(); |
|
|
|
|
// System.out.println("Epoch #" + epoch + " Error:" + train.getError());
|
|
|
|
|
// epoch++;
|
|
|
|
|
epoch++; |
|
|
|
|
} |
|
|
|
|
while (train.getError() > NN_TRAINING_ERROR); |
|
|
|
|
System.out.println("The error of " + train.getError() + " was reached in " + epoch + " iterations."); |
|
|
|
|
train.finishTraining(); |
|
|
|
|
System.out.println("Training completed."); |
|
|
|
|
|
|
|
|
@ -148,11 +149,11 @@ public class BattlefieldParameterEvaluator { |
|
|
|
|
// Simulate the neural network with the test samples and fill a matrix
|
|
|
|
|
for (int NdxBattleSize = 0; NdxBattleSize < NUMBATTLEFIELDSIZES; NdxBattleSize++) { |
|
|
|
|
for (int NdxCooling = 0; NdxCooling < NUMCOOLINGRATES; NdxCooling++) { |
|
|
|
|
// Get the output data using teached neural network
|
|
|
|
|
// Get the output data using taught neural network
|
|
|
|
|
BasicMLData input = new BasicMLData(MyTestData[NdxCooling + NdxBattleSize * NUMCOOLINGRATES]); |
|
|
|
|
final MLData output = network.compute(input.clone()); |
|
|
|
|
double MyResult = output.getData()[0]; |
|
|
|
|
MyValue = ClipColor(MyResult); |
|
|
|
|
MyValue = ClipColor(MyResult * 2); |
|
|
|
|
MyColor = new Color((float) MyValue, (float) MyValue, (float) MyValue); |
|
|
|
|
OutputRGBint[NdxCooling + NdxBattleSize * NUMCOOLINGRATES] = MyColor.getRGB(); |
|
|
|
|
} |
|
|
|
@ -160,7 +161,8 @@ public class BattlefieldParameterEvaluator { |
|
|
|
|
System.out.println("Testing completed."); |
|
|
|
|
// Plot the training samples
|
|
|
|
|
for (int NdxSample = 0; NdxSample < NUMSAMPLES; NdxSample++) { |
|
|
|
|
MyValue = ClipColor(FinalScore1[NdxSample] / BATTLE_MAX_SCORE); |
|
|
|
|
// MyValue = ClipColor(FinalScore1[NdxSample] / BATTLE_MAX_SCORE);
|
|
|
|
|
MyValue = ClipColor(2 * FinalScore1[NdxSample] / 250); |
|
|
|
|
MyColor = new Color((float) MyValue, (float) MyValue, (float) MyValue); |
|
|
|
|
int MyPixelIndex = (int) (Math.round(NUMCOOLINGRATES * ((GunCoolingRate[NdxSample] / MAXGUNCOOLINGRATE) - 0.1) / 0.9) + Math |
|
|
|
|
.round(NUMBATTLEFIELDSIZES * ((BattlefieldSize[NdxSample] / MAXBATTLEFIELDSIZE) - 0.1) / 0.9) |
|
|
|
|