[Home]Justin Mallais

Robo Home | Changes | Preferences | AllPages

Showing revision 12
I'm 32 years old , and though I always had an interest in programming (ever since I got that Commodore64 when I was 8) I've never persued it till RoboCode. I did have an encredibly boring turbo-pascal (teacher) / class in high school which hence I rarely showed up for :P So it's been a hard learning curve, but RoboCode is equally addictive :) My obsession started about 5-6 months ago and the girl-friend I know is starting to wonder :P

I just released my first advanced-bot : JavaDisturbance? V0.59 .. which has been a work in progress, mostly a test-bed for me to learn. but I am inspired by it ranking 66 after 600 battles. :)

I made an Anti gravity movement scheme for it; I played around and learned from basicSurfer tutorialBot, which I used as a start point to make my guessFactor Targeting Gun. I have since found the GFTargeting bot (tutorial) which has code is 100 times more effient than mine.. :) but I opted to keep the code I worked hard for :) though I did improve the manner I segment. In keeping with that spirit I have removed the wave Surfing Code it had and used when it fought 1vrs1. I hope to add my own 1 on 1 code in the future.. likely an implement of waveSurfing of some sort..

I have not figured out how to properly declare/store data on multiple enemies for Melee, making use of The global Static Variables to hold the data for me between rounds... I'll paste the base of my code structure here, in hopes One of you can help me prevent it from writing to disk between rounds... After that fix, I think I ready to start a fresh bot :)

I am oblivious to proper coding practices and what not . Please help.. The internal class: wholeTank which I store in tankList (an ArrayList). I want the wholeTank class to retain its data between rounds.. heres the pertaining code :



package jlm;

import robocode.*;
import robocode.util.Utils;
...

public class javaDisturb extends AdvancedRobot {
	

static ArrayList tankList;     //  arrayList for all the tanks 
...
// other declarations
	
	public void run() {      /// ran once
	
// I set up the set up a 2D arrayList  and add some default Data		
		tankList = new ArrayList();
		for(int i = 0; i < (getOthers() +1); i++) { 
			wholeTank wt= new wholeTank();
			if (i == 0) {wt.name = getName();}	// reserve [0] location for self
			wt.alive=true;
			...
				// other startup defaults
			...
			wt.factorsRestored=false;
			
			wt.dataList = new ArrayList(); 				//creates new dataList
			for (int j = 0; j < 6 ; j++){ 				//adds some default Data to dataList
    			newData = new Tanks();   				
				newData.energy = 100;
				newData.scanTime=0;
	     		newData.absBearing = 0;
				
				if (i == 0) {newData.name = getName();}	// reserve [0] location for self
			wt.dataList.add(newData);
			}
			tankList.add(wt);
			
			
		}
/* **********************              Main Loop             *********************** */

		
		while(true){ 
			updateSelf();
			updateBullets(); // enemy bullets that were detected
			upDateWaves(); // my waves produced every scanRobotEvent for each bot
			antiGravMove(getX(),getY());
			doRadar();
			chooseFirePower(3);
			aim();
			setFire(firePower);
					
            execute();
		}
	}


	public void onScannedRobot(ScannedRobotEvent e) {
		
	
		newData = new Tanks();
		
			
	        newData.energy = e.getEnergy();
                newData.scanTime = getTime() - 1;
                newData.speed = e.getVelocity();
		newData.location = //  .. ect
//		...
//		...
		updateTanks (newData); // this adds the (newData) to the dataList array.  



	class wholeTank{
		String name;
		boolean alive;
		double firedAt;				 // stats  //counts # of times we fire at this tank
    	double hit; 					//stats // counts number of times we hit this tank
		ArrayList dataList;
		public boolean factorsRestored;
		public byte	[]
					[]
					[]
					[]
					[]
					[] statBuffers; //GF Stats
		
	}	

	class Tanks {  
		String name;
		public long scanTime;  //game time that the scan was produced
		public double energy;
		public Point2D.Double location;
		...
		// other data to store
	
		public Tanks() { }
	
	}
	


}



I'm pretty sure the reason your tankList variable isn't working is because of the way your "tankList = new ArrayList();" section is at the start of the run() method. Note that the run() method runs once per round, meaning that even though tankList is static, it's being overwritten by a new list every round. To fix it I'd suggest putting that code to create the list inside and if block like "if (tankList == null)" so you'll only run it once out of all the rounds. -- Rednaxela

wow, cool, never expected that.. will try asap in the morning !! :)

Welcome to the wiki! =) Please do feel free to ask questions, it's a pretty helpful community. Good luck to you and your bots. (Oh, and you should make a page for your bot!) -- Voidious

Thx Voidoius for the welcome :)-Justin

YES Rednaxela !! that was the case!!! Thx for the help :) I probally would never of thought of it.. -Justin

No problem! And like I forgot to say before, welcome to the wiki! :) -- Rednaxela

Hey guys ! I'mm back at it again :) I recently threw Justin.MallaisV8? in to the mix.. :) Inspired by it's new gun and my improved coding/underStanding I have since completely rewritten it. I am happy with my progress, but once again I'm hoping someOne can help me out with a semantic Error I can't figure out. :

Found 1 semantic error compiling "C:/robocode/robots/justin/Mallais.java":

    18. public class Mallais extends AdvancedRobot {
                     ^-----^
*** Semantic Error: The class file "BulletHitEvent.class" in "libs\robocode.jar\robocode" has an invalid format (duplicate local variable type table).
Compile Failed (1)

   I'll post code if needed..
Thx - Justin


Robo Home | Changes | Preferences | AllPages
Edit revision 12 of this page | View other revisions | View current revision
Edited April 21, 2009 1:40 EST by CPE0011d8d68637-CM001ceacce44e.cpe.net.cable.rogers.com (diff)
Search: