Difference between revisions of "Talk:DemonicRage"

From Robowiki
Jump to navigation Jump to search
m (→‎Comments: typo)
Line 198: Line 198:
  
 
Very nice! Seems you've won the race to melee surfing? (EDIT: To melee surfing that collects stats I meant. Since [[Talk:Wave_Surfing/Melee|apparently]] Shadow does do non-learning wave surfing in melee, and while I believe Portia learns a little about enemy targeting it's not technically a wave surfer) I'm a little surprised by DemonicRage still performing behind Glacier though. Perhaps do some 1v1 tests of the surfing to see how well it's working in a more basic situation? --[[User:Rednaxela|Rednaxela]] 15:16, 23 April 2010 (UTC)
 
Very nice! Seems you've won the race to melee surfing? (EDIT: To melee surfing that collects stats I meant. Since [[Talk:Wave_Surfing/Melee|apparently]] Shadow does do non-learning wave surfing in melee, and while I believe Portia learns a little about enemy targeting it's not technically a wave surfer) I'm a little surprised by DemonicRage still performing behind Glacier though. Perhaps do some 1v1 tests of the surfing to see how well it's working in a more basic situation? --[[User:Rednaxela|Rednaxela]] 15:16, 23 April 2010 (UTC)
 +
 +
Thanks, your right... I haven't really tested the 1vrs1. The only difference between the melee and 1vrs1 is seperate Stats, which are both non-Segmented. I haven't tried segmenting yet, but I'm sure the 1vrs1 needs it. -[[User:Jlm0924|Jlm0924]] 17:35, 23 April 2010 (UTC)

Revision as of 19:35, 23 April 2010

DemonicRagev3.0

Lately I have completely rebuilt and improved Demonics foundation (still based on Module) I implemented Rednaxela's tree into a bare bones version of D's gun, which I plan to later expand after the new movement is fleshed out. The gun's new PIF I made should be quite quick. I'm not sure how it compares to displacement vectors or if it's type has been done before, but I will post it and D's Radar source code next chance I have.
I released DR3.0 early. I just got the melee movement working and the gun is untuned. 1vrs1 is temperarily random. I should of disabled some painting and tested for skipping turns, but it seems fine. -Jlm0924 17:11, 20 April 2010 (UTC)


Source Code

I left it as is, with code commented out in case someOne wants to play with it..


/* author: Justin 
  
*/
package justin.radar;



import robocode.Event;
import robocode.ScannedRobotEvent;
import robocode.RobotDeathEvent;
import robocode.util.Utils;
import justin.Module;
import justin.Radar;
import justin.Enemy;
import java.util.Iterator;
//import java.awt.geom.Point2D;
//import java.awt.Graphics2D;


public class DynamicLocking extends Radar {
	
	public DynamicLocking(Module bot) {
		super(bot);
	}
	
	
	static final double PI = Math.PI;
	static double radarDirection = 1;
	static Enemy lookingFor = new Enemy();;
	
	
	public void scan(){  
		
		if(bot.getRadarTurnRemaining()==0 ){	
			double radarTurn = Double.POSITIVE_INFINITY * radarDirection;
			bot.setTurnRadarRightRadians(radarTurn);// the scan
			
		}
	}
	
	
	
	public void listen(Event e){
	if (e instanceof RobotDeathEvent && (( RobotDeathEvent)e).getName()== lookingFor.name){
		if(bot.enemy!=null) lookingFor.name=bot.enemy.name;
	}
		if (e instanceof ScannedRobotEvent){
			if(Module.enemies.size() < bot.getOthers()) return; // not perfect
			if(lookingFor.name == null)lookingFor.name = ((ScannedRobotEvent) e).getName();
			if( ((ScannedRobotEvent) e).getName()==lookingFor.name) {
				Iterator<Enemy> iterator= Module.enemies.values().iterator();
				double bestScore=Double.POSITIVE_INFINITY;
				
				while (iterator.hasNext()){
					Enemy tank= iterator.next();
					if(tank.alive){	 // choose next tank to scan
						double time = tank.scanTime;
						double sweepSize = (Math.abs(Utils.normalRelativeAngle(tank.absBearingRadians - bot.getRadarHeadingRadians())) /PI); //1 needs the scan
						int distance = (int)Math.round((Math.min(1000,tank.distance)/1000*3)); // 1  needs the scan
						distance = ( distance ==3 && bot.getOthers()>4 ) ? 10 : 0; 	// farthest not a concern
			//			int priority = 0;
			//			if( (tank.name==bot.enemy.name || tank.name == bot.myClosestBot.name || bot.myLocation.distance(tank.location)<tank.cbD || bot.getOthers()<4)){
			//				priority = -5;
			//			}
					
						double score = time - sweepSize;// + distance + priority;
						// scan target before he fires
/*						double ang = lookingFor.absBearing + (lookingFor.deltaAbsBearing);
						double turnsB4ScanBot = Utils.normalRelativeAngle(Math.abs( (bot.getRadarHeadingRadians()-ang) ))/.785;
						double sS = bot.getTime()-lookingFor.timeScanned;
						if(enemy.name == lookingFor.name && (bot.getGunHeat()/bot.getGunCoolingRate())-turnsB4ScanBot < 2 && sS > 1)score=score-25;
*/				
					//  scan Target before we fire at him
	/*					if (tank.name==bot.enemy.name  &&  ticksUntilGunCool() < bot.enemy.timeSinceLastScan +2 ) { 
							score = score - 10; // score is based on time
						}
	*/			
						if(score < bestScore){
							bestScore = score;
							lookingFor = tank;
					
						}	
					}
				}

				
				
				// the scan
				
				double angle = lookingFor.absBearingRadians-(lookingFor.deltaAbsBearingRadians*2); // + lookingFor.deltaBearing;// should be much more accurate to use below
				radarDirection =(int) Math.signum(Utils.normalRelativeAngle(angle - bot.getRadarHeadingRadians()));
			    double turnsTillScanBot = Utils.normalRelativeAngle(Math.abs( (bot.getRadarHeadingRadians()-angle) ))/.7;	
				double radarTurn = Double.POSITIVE_INFINITY * radarDirection;
				//	int timeSinceScanned = (int) bot.getTime()-lookingFor.timeScanned;
				
				// radar Lock
				if(lookingFor.deltaScanTime < 1.1 && turnsTillScanBot < 1){ 
					//System.out.println(lookingFor.deltaBearing+"  ss  "+lookingFor.timeSinceLastScan+"  d  " +lookingFor.distance);			
					double offset =0;// = radarsMaxEscapeAngle(lookingFor.distance,sinceScanned) * radarDirection;   //  a small offset based on escape angle
					offset = offset + ( Math.abs(lookingFor.deltaAbsBearingRadians * 3 )   ); // greater offset for lateral speed
					offset = offset +  (20* (lookingFor.deltaScanTime))  / (lookingFor.distance); // greater offset for smaller distance
					offset = offset * radarDirection;	
					
					radarTurn =(Utils.normalRelativeAngle(angle - bot.getRadarHeadingRadians()+offset));
				}
				
				bot.setTurnRadarRightRadians(radarTurn);// the scan
			
			}
		}
	}
/*		
	public void onPaint(Graphics2D g){
		if(lookingFor!=null&&lookingFor.location !=null){
		g.setColor(new Color(0, 0, 255, 70));	
		g.fillRect((int)lookingFor.location.x-25,(int)lookingFor.location.y-25,50,50);
		}
		
	}
*/	
	// utils
/*	
	protected long ticksUntilGunCool() {
	        return Math.round(Math.ceil(bot.getGunHeat() / bot.getGunCoolingRate()));
	}
	

	

	
	public static double radarsMaxEscapeAngle(double distance, double sinceScanned) {
        return Math.asin( 8/    (distance-(8*sinceScanned))) * sinceScanned ;// 
    }

*/
    
    
    

}			

///// DataLog is a linked list of scan info(I should rename it to HistoryLog). //Enemy is additional scan info (current)
//Play It Forward by Justin  , (Using Rednexnala's FastTrig)	
	
	public Angle getGunAngle(DataLog similar, Enemy e ,double bulletSpeed, long time, double weight){// GunData predictedInfo, Enemy e) {
		
		final DataLog  predictedInfo =  similar;
		final DataLog currInfo = e.last;
		DataLog endInfo = predictedInfo;
		double bulletTime;
		long timeDelta = (time  - currInfo.scanTime);
		double  predDist = 0, predAng;
		Point2D.Double myRelativePosition = project(predictedInfo.location, Utils.normalRelativeAngle(currInfo.absBearingRadians + FastTrig.PI-currInfo.headingRadians+predictedInfo.headingRadians), currInfo.distance);
			while (endInfo.next != null && endInfo.round == predictedInfo.round && endInfo.scanTime >= predictedInfo.scanTime ) {
				
				endInfo = endInfo.next; 
				bulletTime = (myRelativePosition.distance(endInfo.location) / bulletSpeed) +1;
			    if (Math.abs(endInfo.scanTime - predictedInfo.scanTime - timeDelta - bulletTime) <= 1) break;
			}
			if ( endInfo.next == null | endInfo.round != predictedInfo.round )return null; 
			
			predAng = Utils.normalRelativeAngle(DRUtils.absoluteBearing(predictedInfo.location, endInfo.location)
					- predictedInfo.headingRadians );
			predDist = predictedInfo.location.distance(endInfo.location);
			Point2D.Double predLocation = project(currInfo.location,Utils.normalRelativeAngle(predAng+currInfo.headingRadians),predDist);
			if(!Module.bf.contains(predLocation)) return null;
			
			predAng = DRUtils.absoluteBearing(bot.myData.location, predLocation);
			predDist = bot.myData.location.distance( predLocation);
			
			Angle angle = new Angle( predAng, FastTrig.atan(18 / predDist), 0, weight );
		// returns:  predicted angle,  tolerence,  
		return angle;
	}
	


Comments

Very nice! Seems you've won the race to melee surfing? (EDIT: To melee surfing that collects stats I meant. Since apparently Shadow does do non-learning wave surfing in melee, and while I believe Portia learns a little about enemy targeting it's not technically a wave surfer) I'm a little surprised by DemonicRage still performing behind Glacier though. Perhaps do some 1v1 tests of the surfing to see how well it's working in a more basic situation? --Rednaxela 15:16, 23 April 2010 (UTC)

Thanks, your right... I haven't really tested the 1vrs1. The only difference between the melee and 1vrs1 is seperate Stats, which are both non-Segmented. I haven't tried segmenting yet, but I'm sure the 1vrs1 needs it. -Jlm0924 17:35, 23 April 2010 (UTC)