View source for Talk:Opposite

From Robowiki
Revision as of 22:00, 12 September 2009 by CrazyBassoonist (talk | contribs) (Codesize)

Talk:Opposite
Jump to navigation Jump to search

Any ideas for a targeting scheme with 132 bytes? (including how to select a target) --Starrynte 17:45, 12 September 2009 (UTC)

I'm not sure how much this will help, but this is the enemy selection I tend to use in codesize-restricted melee bots. I used linear targeting in this example:

package oog.nano.aorta;

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

public class Aorta extends AdvancedRobot {
	static double enemyDist;
	static String enemyName;
	public void run(){
		enemyDist=Double.POSITIVE_INFINITY;
		setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
	}
	public void onScannedRobot(ScannedRobotEvent e){
		if(e.getDistance()<enemyDist||e.getName()==enemyName){
			enemyName=e.getName();
			enemyDist=e.getDistance();
			
			//This part greatly increases the accuracy of the targeting, but it isn't necessary.
			if(getGunHeat()<1){
				setTurnRadarLeftRadians(getRadarTurnRemainingRadians());
			}
			
			/*
			*You could replace these next two lines with any type of targeting and bullet power you like, 
			*I just used linear targeting as an example.
			*/
			setTurnGunRightRadians(Utils.normalRelativeAngle((e.getBearingRadians()+getHeadingRadians())-getGunHeadingRadians())+
					(e.getVelocity()*Math.sin(e.getHeadingRadians()-(e.getBearingRadians()+getHeadingRadians())))/14);
			setFire(2);
		}
	}
	public void onRobotDeath(RobotDeathEvent e){
		enemyDist=Double.POSITIVE_INFINITY;
	}
}

Note: I'm almost certain that this will fit into 132 bytes. If you need to put something else in, you could change it to head-on targeting or remove the line that locks on the radar before firing. Just remember that that line is pretty important for making the gun accurate--CrazyBassoonist 18:14, 12 September 2009 (UTC)

OK thanks, except should I do e.getName().equals(enemyName) as opposed to e.getName() == enemyName? --Starrynte 19:01, 12 September 2009 (UTC)

No problem. And using e.getName().equals(enemyName) would work, but costs three more codesize bytes--CrazyBassoonist 20:00, 12 September 2009 (UTC)

Contents

Thread titleRepliesLast modified
Code213:27, 4 May 2019

Hi, very nice robot! I like its colors =) I've been thinking of a melee robot that uses stop and go and fluid movement, but I don't know how to implement fluid movement :/ Could I take a peek at your code just to see how it's done? Thanks!

Slugzilla (talk)00:01, 2 May 2019
I don't think Starrynte is active anymore. Fluid movement is just like Anti Gravity movement but what you do is to move perpendicular to the forces rather than getting away from them.
It gives you two main advantages:
  1. You can dodge bullets when they are coming right at you
  2. It makes wall smoothing easier
The direction you are going to move is just like in RandomMovementBot which implements a type of fluid movement without anti-gravity spots.
Dsekercioglu (talk)17:46, 3 May 2019

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:Talk:Opposite/Code/reply (2).