package bot1; import robocode.*; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.PrintStream; import java.util.Random; public class CooperBot1 extends AdvancedRobot { static double mutationProbability =0.05; static int StartingPop=10; String currentGenome; int currentBotRound; int A,B,C,D,E,F,G; int counterHits, counterFired; static int ScoreArray[][]=new int[StartingPop][2]; public void run() { counterHits=0;counterFired=0; currentBotRound = getRoundNum(); try { BufferedReader r = new BufferedReader(new FileReader(getDataFile("Populations.txt"))); } catch (IOException e){ createStartPopulations(); } importCurrentGene(); out.print(currentGenome); String[] temp; String delimiter ="-"; temp= currentGenome.split(delimiter); A=Integer.parseInt(temp[0]); B=Integer.parseInt(temp[1]); C=Integer.parseInt(temp[2]); D=Integer.parseInt(temp[3]); E=Integer.parseInt(temp[4]); F=Integer.parseInt(temp[5]); G=Integer.parseInt(temp[6]); while(true) { // Replace the next 4 lines with any behavior you would like ahead(A); turnGunLeft(B); back(C); turnGunRight(D); } } /** * onScannedRobot: What to do when you see another robot */ public void onScannedRobot(ScannedRobotEvent e) { // Replace the next line with any behavior you would like stop(); setFire(E); stop(); } /** * onHitByBullet: What to do when you're hit by a bullet */ /** * onHitWall: What to do when you hit a wall */ public void onHitWall(HitWallEvent e) { // Replace the next line with any behavior you would like back(F); turnRight(G); } public void onBattleEnded(BattleEndedEvent e){ int temp[] =new int[2]; for (int i = 0; i < ScoreArray.length-1; i++){ for(int j=0; j ScoreArray[j+1][0]){ temp[0] = ScoreArray[j][0]; temp[1] = ScoreArray[j][1]; ScoreArray[j][0] = ScoreArray[j+1][0]; ScoreArray[j][1] = ScoreArray[j+1][1]; ScoreArray[j+1][0] = temp[0]; ScoreArray[j+1][1] = temp[1]; } } for(int i=0;icounter)&&(selector<=(counter+chanceSelection[i]))) { selectedPairRound[j]=ScoreArray[q][1]; break; } else{ q++; counter+=chanceSelection[i]; } } } try { BufferedReader r = new BufferedReader(new FileReader(getDataFile("Populations.txt"))); for (int j=0;j<2;j++){ for(int i=0;i