[Home]HaikuGoTo

Robo Home | Changes | Preferences | AllPages

This is a haiku version of Movement/GoToBot, except it doesn't fire (i needed 2 more lines for that). I think it works, and is only 4 lines, but please check for me. -- Tango

package tango.haiku;
import robocode.*;
import java.awt.geom.*;

public class HaikuGoTo extends AdvancedRobot
{
	double ran, ran2;
	public void run() {
		setTurnGunRight(Double.POSITIVE_INFINITY);
		while(true) {
			turnRight(Math.toDegrees(Math.atan2(((ran=Math.random())*(getBattleFieldWidth()-36)+18)-getX(),((ran2=Math.random())*(getBattleFieldHeight()-36)+18)-getY()))-getHeading());
			ahead(Point2D.distance((ran*(getBattleFieldWidth()-36)+18),(ran2*(getBattleFieldHeight()-36)+18),getX(),getY()));
		}
	}

}

Actually, since you're already spinning your gun, you only need one more line to fire. But I think this maybe can be done with firing in a HaikuBot, maybe I'll give that a shot sometime... -- Kawigi

package tango.haiku;
import robocode.*;
import java.awt.geom.*;

public class HaikuGoTo extends AdvancedRobot
{
	double ran, ran2;
	public void run() {
		setTurnGunRight(Double.POSITIVE_INFINITY);
		while(true) {
			turnRight(((fireBullet(3) == null)?1:1) * Math.toDegrees(Math.atan2(((ran=Math.random())*(getBattleFieldWidth()-36)+18)-getX(),((ran2=Math.random())*(getBattleFieldHeight()-36)+18)-getY()))-getHeading());
			ahead(Point2D.distance((ran*(getBattleFieldWidth()-36)+18),(ran2*(getBattleFieldHeight()-36)+18),getX(),getY()));
		}
	}

}

This one aims and has a line to spare if I understand haiku correctly:

package tango.haiku;
import robocode.*;
import java.awt.geom.*;

public class HaikuGoTo extends AdvancedRobot
{
	double ran, ran2;
	public void run() {
		turnGunRight(Double.POSITIVE_INFINITY);
	}

	public void onScannedRobot(ScannedRobotEvent e)
	{
		turnRight(((fireBullet(3) == null)?1:1) * Math.toDegrees(Math.atan2(((ran=Math.random())*(getBattleFieldWidth()-36)+18)-getX(),((ran2=Math.random())*(getBattleFieldHeight()-36)+18)-getY()))-getHeading());
		ahead(Point2D.distance((ran*(getBattleFieldWidth()-36)+18),(ran2*(getBattleFieldHeight()-36)+18),getX(),getY()));
	}
}

With firing! I think, I didn't actually test this. Of course this doesn't aim, but a rewrite to move some things into a scanned method and maybe use an infinite radar could probably handle that, I'm not sure how many lines would turn out. -- Kuuran

What I posted originally didn't work. Does now. -- Kuuran

lol, well, that's creative... Would anybody enter if I made a 4-line bot division in the RobocodeLittleLeague? -- Kawigi

I might be interested, depends on how the competition is, no competition doesn't make for a fun league. -- Kuuran

I'm guessing it will be hard to beat HaikuWalls? in melee (although HaikuCircleBot doesn't do bad) and there are a few decent 1-on-1 haiku's, as well (HaikuChicken beats NanoSatan sometimes, I think). -- Kawigi

It does, impressive. I need to rewrite his matcher so it stops taking forever to pick up that a target has stopped (frequent wide firing when it stops seems to be where it's picking up most of it's points). If a new nano contest does start up I'll seriously consider revamping NanoSatan to be competitive and working on some Haikus, I'm certainly not making much progress on my MegaBot. -- Kuuran

I realised i only needed one more line when i woke up this morning. The line i had removed was setAdjustGunForRobotTurn(true), which although nice, is not actually needed. You're latest is only 3 lines if i'm counting right (do declarations count as lines?), so you could have the fire() separate, and it would look much better:

package tango.haiku;
import robocode.*;
import java.awt.geom.*;

public class HaikuGoTo extends AdvancedRobot
{
	double ran, ran2;
	public void run() {
		turnGunRight(Double.POSITIVE_INFINITY);
	}

	public void onScannedRobot(ScannedRobotEvent e)
	{
		fire(3);
                turnRight((Math.toDegrees(Math.atan2(((ran=Math.random())*(getBattleFieldWidth()-36)+18)-getX(),((ran2=Math.random())*(getBattleFieldHeight()-36)+18)-getY()))-getHeading());
		ahead(Point2D.distance((ran*(getBattleFieldWidth()-36)+18),(ran2*(getBattleFieldHeight()-36)+18),getX(),getY()));
	}
}

-- Tango

PS. I would be up for a haiku division in a league. It would be more about skill than having too much time on your hands, which the megabots are a bit. -- Tango

Indeed, I left the latest with the in-line fire because I wanted to show that the line remained for expansion. As for variable declarations, that's a very good question, I was just logging on to ask it myself. -- Kuuran

I think that trick with putting fire in another line is just cheating. It's not making a bot that is only 4 lines, it's making a bot that is 5 lines and pretending it's only 4. -- Tango

I believe declarations do count, so you'd probably have to put the inline fire back in. There will be another small-bot competition soon, I'm working out the details right now. If I do add a Haiku-league, it will be dissimilar to the FemtoBot experiment (Mike will want to kill me...) in that it won't be about making the smallest codesize for an effective robot (which is how HaikuBots started), but rather a league where every competitor is limited to 4 Semicolons, not including imports/package declarations (that also means that all will have to be open source, hope that doesn't bother anyone). -- Kawigi

Open source is unavoidable. If we are doing it by semi colons, then i'm perfectly happy to accept Kuuran's inline fire() and suchlike. If we were going on "poetic purity", then i wouldn't, but as long as everyone has the same rules, it is fair. Will you be doing separate 1v1 and melee haiku leagues? What will be the rules regarding originality? There are a lot of haiku bots open source already, that people could use. Yours for instance. -- Tango

There would be seperate melee and haiku leagues. I suppose the hard part in doing this would be getting everyone to give unique names to their Haiku's (I.e.- not having 3 HaikuTrackers and 2 HaikuRamfire?'s). -- Kawigi

I guess the majority concensus has been that they do count, but if you're running the league I'm going to ask you to consider these ambiguous cases: A variable declaration. A variable declaration with initialization. Are they the same? Do both count as lines? -- Kuuran

My response - be as creative as you can, and use as few semicolons as possible. I'll leave it at that, full knowing that some HaikuBots may be MicroBots by codesize. It would probably make sense to attempt to declare every variable you use (if you use variables) on one line. I don't much care about assignment, global variables are going to be assigned zero or null values anyways. -- Kawigi

I say we go purely on number of semi-colons. In the whole thing, including declaratations, imports, etc. So, if we allow 4 lines or active code, 1 line of declaration, and 2 imports/packages that is a maximum of 7 semi-colons. You can use the semi-colons in different places if you want, basically meaning perceptual bots get 5 lines, instead of 4. -- Tango


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited May 5, 2006 8:24 EST by Florent (diff)
Search: