package cx.haiku; import robocode.*; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; /** * @author iiley * MeleeXaxa can goes to the nearest corner to do corner move and choose the nearest enemy to shoot */ public class MeleeXaxa extends AdvancedRobot { Rectangle2D.Double leftTop,leftBottom,rightTop,rightBottom,nextPoint,myPoint, movePoint=new Rectangle2D.Double(0,0,0,Math.PI*2), closest=new Rectangle2D.Double(Double.POSITIVE_INFINITY,0,0,0), lastFireTime=new Rectangle2D.Double(0,0,0,0); public void run() { while( (leftTop=new Rectangle2D.Double(20,getBattleFieldHeight()-150,150,getBattleFieldHeight()-20))!=null && (leftBottom=new Rectangle2D.Double(20,150,150,20))!=null && (rightTop=new Rectangle2D.Double(getBattleFieldWidth()-150,getBattleFieldHeight()-20,getBattleFieldWidth()-20,getBattleFieldHeight()-150))!=null && (rightBottom=new Rectangle2D.Double(getBattleFieldWidth()-150,20,getBattleFieldWidth()-20,150))!=null && (myPoint=new Rectangle2D.Double(getX(),getY(),0,0))!=null ){ if( (getTime()<36 ? //((movePoint.x=myPoint.x-Math.sin(getHeadingRadians())-0.1)>0 ? movePoint.y=myPoint.y-Math.cos(getHeadingRadians()) : 1) //turn body 360 degree first to scan,startup the radar 1 : (( myPoint.x<getBattleFieldWidth()/2 ? (nextPoint=myPoint.y>getBattleFieldHeight()/2 ? leftTop : leftBottom) : (nextPoint=myPoint.y>getBattleFieldHeight()/2 ? rightTop : rightBottom) ).x) )>0 && ( getTime()>36 && (movePoint=(getTime()-36)/25%2==0 ? new Rectangle2D.Double(nextPoint.x,nextPoint.y,0,0) : new Rectangle2D.Double(nextPoint.width,nextPoint.height,0,0) )!=null ) ){ setAhead( ( ( movePoint.width = robocode.util.Utils.normalRelativeAngle( Math.atan2( movePoint.x-myPoint.x, movePoint.y-myPoint.y) - getHeadingRadians() ) ) == ( movePoint.height = Math.atan( Math.tan( movePoint.width ) ) ) ? 1 : - 1 ) * new Point2D.Double(movePoint.x,movePoint.y).distance(new Point2D.Double(myPoint.x,myPoint.y)) ); } //move towards point turnRightRadians( movePoint.height ); } } public void onScannedRobot(ScannedRobotEvent e) { if(e.getDistance()<closest.x+150 && (closest.x=e.getDistance())>0 || getTime()-lastFireTime.x>48) if( ((getEnergy()>0.11d || e.getEnergy()==0d) && setFireBullet(Math.min(900d/e.getDistance(),Math.min(getEnergy()/5d,Math.min(3d,e.getEnergy()/6d))))!=null && (lastFireTime.x=getTime())>0) && (closest.x=Double.POSITIVE_INFINITY)>0 || true ) setTurnGunRight(Double.POSITIVE_INFINITY); } }
Amazing. Though it's still just an effect of the not-so-thought-through descision to count semicolons instead of active lines. I wonder what Tobe would think about this haiku development. =) I do think we should reconsider how lines should be counted. MeleeXaxa is impressive but should really compete in a division named "FourSemiColons?". -- PEZ
On a more important note. iiley, it seems, in my tests, like Xaxa clearly outperfroms MeleeXaxa in melee battle with eight combatants. With the current competitors in LittleLeague haiku melee I would think Xaxa would win and in femto melee I think Trigon will be winner. But we haven't seen the PheonixHaikuMelee? and PheonixFemtoMelee? bots yet of course. -- PEZ
I think FemtoBots are better because they avoid things like this. A bot really has to be simple and effective to win in Femto. Haiku is just cramming anything you want into 4 lines. -- Tango
Or, as it is defined now, cramming anything you want into four semicolons. Consider this bot:
public class HaikuRidicule extends AdvancedRobot { public void run() { setTurnGunRightRadians(Double.POSITIVE_INFINITY); } public void onScannedRobot(ScannedRobotEvent e) { for (int i = 0; i < 1; setTurnRight(e.getBearing() + 80), setAhead(100 * Math.sin(getTime() / 12) ), setTurnGunLeftRadians(getGunTurnRemainingRadians()), fire(2.1), i++) { } double justToMakeitFour; } }-- DonQuijote
Oh~~~Cool,DonQuijote,this seems that semicolons counting is useless now,every thing can do in one semicolon,~;[,i have not to make or improve haikus and sonnets before Kawigi give another way to counting lines.(I just want to improve MeleeXaxa when i back home,fortunately,i saw this first) -- iiley
To PEZ,yes MeleeXaxa can not did better than Xaxa,both 1v1 and melee,I think the haiku melee #1 will be WallsPoetHaiku,in my testing,it wins more times than Xaxa.Today afternoon i have a idea to improve MeleeXaxa,maybe with the improvement it can did better,i hurry go back home,but i saw HaikuRidicule?.~;[ -- iiley
Don't let my ridicule stop you from improving this bot. I always think you should work with the rules given. Even if I sometimes think the rules are not-perfect. Note that my HaikuPoet also takes advantage of the semicolon-vulenerability of the rules. Albiet maybe not to the same extent as Meleexaxa. =)
As for Xaxa or my WallsPoetHaiku, I also thought my walling bot had an edge, but I ran 10000 rounds over the night and Xaxa was a clear winner. Since none of the bots saves any data between rounds I draw the conclusion Xaxa is the stronger one. -- PEZ
But,if i use for(),maybe i can squeez Nimrod to be a haiku,or others can make their big melee bot to be a haiku,when i think of this,i have no hope to do improving MeleeXaxa,just wait....hehe~~~however i can have a rest. ~;] -- iiley
You can't do everything in there. It would be interesting to see DT as a haiku, because it would have to be open source then. =) -- PEZ
Using the for() trick you can only have one block of code, so no onHitWall?, onHitByBullet?, onDeath, onCustomEvent, and so on. Very restrictive for turning true megabots into haikus. -- Tango
A bot basically needs four individual elements that can't be embedded without using the for() trick. Radar control, gun turning control, direction control, turning control. Firing is a fifth, but easily embedded. However, radar control requires two lines to lock; so, not using the for() trick you had five lines of code that couldn't be embedded (2xradar, gunturn, ahead, robotturn) to go into four slots (your four semi-colons). That, to me, left a genuine art and trade-off to this. Now that PEZ has pointed out the for() trick (that I'm sure many of us should have remembered) I don't see any point to writing haikus. You're just making perceptual minis.
I suggest we count the comma seperators used for stacking instructions in a for() statement the same as semi-colons. -- Kuuran
They don't have to be perceptual, either (MeleeXaxa isn't, following the example of an almost-haiku attempt I showed Iiley before). I'd be more inclined to outlaw for loops, because they're rarely worth the pair of semicolons unless you do this. -- Kawigi
I would just stop worrying about haikus and just make femtos. The original haikus were made because it was discovered that the best femtos had 4 lines, that is the real idea behind haikus, the 4 lines is a co-incidence, the codesize is what is important. A HaikuMina? is a contradiction in terms. The 4 line haiku is simply a corruption of the idea. -- Tango
Never the less there's lots of Robocode tradition in haikus. I think we should keep them. But we should ask ourself the question if MeleeXaxa is in the spirit of haiku bots or not? I am very impressed by MeleeXaxa, and I wouldn't have thought it was possible if not iiley had done it. But my answer to the question I propose is "no", it's not. Haiku should be short and to the point I think. I'd say we use Tobe's definition instead and use a jury of sorts to judge when a bot is haiku or not. Such a jury might choose to disqualify or allow HaikuPoet 0.2 for instance. After a while we'll surely get enough prejudication cases to be able to judge quite easily. -- PEZ
And, in Java programming in general, "for" loops are very often to prefer before while loops. In these cases they are always "worth" the two semicolons. Disallowing them would be in the completely wrong direction when it comes to aiming at sound programming principles. "for" loops allow localizing of iteration variables, something that is very, very good. "while" loops does not. "for" loop are also used for many high perfomance idioms for iteration over lists and such. "for" loops are good, beautiful and neat. -- PEZ
Using the for loop trick will usually require a bot be perceptual, however - that's where the statement came from. Two semicolons in a for loop (which is probably in an event handler), one to spin something so it starts seeing opponents, only one left. I'm not sure I like the idea of a committee, however. Granted, haikus are supposed to be more of an art than the rest of robocode, but if we're going that way then I don't think combat performance is the best way to judge the haikus which are accepted by the committee. Perhaps we should have voting on which is the most interesting code-wise to judge which are the "best". Something in the way the movement or gun firing expresses itself being witty, intelligent, cute, funny, or whatnot would be the criteria. But I think the whole idea is straying a bit far. (silly edit conflict) -- Kuuran
You are right. As long as we compete in haiku bot performance it's better to measure "haikuness" more mechanically. What about an upper codesize limit to go with the four semicolons? I propose 100 bytes. -- PEZ
Do HaikuBots really lend themselves to competition? Quite a lot of Haikus aren't very good in battles, but are really clever copies of other bots (usually SampleBots). I would say bots like HaikuTracker are better than MeleeXaxa, even though a battle between them would certainly give the oposite results. I think we should use femtos in competition, and have haikus as JustForFun. I think we all know what is an imaginative HaikuBot, we don't need a formal system to decide. We can just informally discuss them as they are posted on the wiki, and a general concensus will probably be easy to come to. -- Tango
Noone has suggested haiku competetion should replace femtos. This is about the LittleLeague haiku division. If bot A beats bot B clearly in battle (and also beats more bots than bot B does) there's no way you can get me to say bot B is better than bot A. That's just silly. Anyone that has been coding Robocode bots for a while knows that its about competition. The JusForFun? things get as little attention as they do because of this. I do think that haiku's can compete. I also think that if you browse Tobes gallary of haiku bots and compare them to some of the haikus competing in LittleLeague you'll see where I am trying to push LittleLeague's haiku division. -- PEZ
Indeed, no-one has suggested replacing femtos, i'm suggesting replacing haikus. A "good" haiku, i would say, is one that is imaginitivly, creatively coded, not one that just uses tricks to get complex things in. The key to haikus is simplicity, not tricks to allow complexity. If a bot can be simple and competitive then great, but i think most will/are just proofs of concept and people trying to show that something can be done in 4 lines. -- Tango
Not any longer. Now we have LittleLeague haiku division. Now it's about winning. -- PEZ
I suppose as the founder of competitive haiku development, I should put in my two cents, too - The original haiku terminology was a descriptive term for the original FemtoBots. Therefore, the Femto division is meant to promote what the original authors of HaikuBots were doing. My intention with creating a haiku league was to see how creative people would be with the ability to only call 4 methods that return void (3 if they choose to not be perceptual). The result I expected of such limitations was, in all fairness, something like MeleeXaxa. -- Kawigi
Well compare the use of these tricks in haikubots to the use of code shrinking techniques in mini/micro/nanobots. There is morally very little difference between the 2. The only way to avoid this kind of thing is to ban the use of the comma, but in truth unless a more specific set of rules are dreamt up, there has to be either no limitations on what you can do or they need to be non-competitive... --Brainfade
I vote for outlawing for loops,because we almost never to do a for loop in a haikus before we know we can embedded many void method in "for()" as HaikuRidicule? did(for loop cost 3 lines,we only can have 4 lines,your bot can not be perceptual).Yes,as PEZ said,for loops are good, beautiful and neat,but only in haikus,we may can quit it. -- iiley
If it's the number of void calls you want to limit, why not just make that the rule? If it's the number of void calls to the Robocode API it's even easy to automate the count since you only need count a set number of method names. That way MeleeXaxa could maybe even be written in a readable way. Just because bad programming habits are encourage in minibot development doesn't say it's just as well we introduce yet another such constraint. But, I'm mainly giving you a hard time here. Count semicolons if you like and ban "for" loops too. I'll just extend my own rule to "never sacrifice clarity for codesize" with "... or semicolon avoidance", and let my DonQuijote bots fight the battle for me. =) -- PEZ
If count the number of robocode API void method,how about the variables(eg. MeleeXaxa's leftTop...),do this will be count or not? -- iiley
Not if we count Robocode API void method calls. It would be normal classes, only restricted in how many things they can ask the robot to do in a turn. -- PEZ
Do many people actually have more than 4 void method calls in a robot? If they do, how many can't be re-written not to need them? If a robot is well written with custom methods to get values to give to the robocode methods, it could well only need a turnRadar(), turnRobot(), turnGun() and ahead() in the run() method and everything else being elsewhere (with fireBullet() being embedded). -- Tango
I think that the semicolon rule would still be in effect (that way you would still have to drop it to 3 to store variables) -- Kawigi
Ah, that might work. We could rephrase it: Only 4 lines are allowed per bot, a line is defined as anything ending in a semicolon, which contains one or no void method calls. Non-lines which include semicolons are not allowed. -- Tango
"Non-lines which include semicolons" - what does that mean? -- Kawigi
I say we go for four semicolons and no "for" loops. Much can be said about MeleeXaxa, but you can't say it's not creative! -- PEZ
As for the four void methods and how many are needed for a bot, I've already discussed that tradeoff somewhat, scroll up :P This is what originally attracted me to the idea of haikus. -- Kuuran
And it's also why I thought a Haiku division might be interesting. -- Kawigi
A non-line containing a semicolon is any use of a semicolon that doesn't fit the definition of a line. So lines with more than one method call, and for loops would not be allowed. -- Tango