|
Here is a Perceptual Couplet Robot Droid to do the job: package bayen; If you wanted to make it better, you could add:
--Bayen MovesWithWind? could be shortened as so:
With a radar with more slip-rate and assigning variables on the same line as declaring them. -- Nfwu |
The challenge I decided to try myself with was to beat MyFirstRobot without firing a shot. It turns out that out-surviving MyFirstRobot without shooting is also somewhat easier than outscoring him. Both can be done, and I'll bet either can be done in a micro-bot (maybe even a minibot). Anyone else feel like trying it?
--Kawigi
Well, I tried to make it a HaikuBot, but it ended up being 6 lines and two variables. Can anyone get it shorter than this?
public class MovesWithWind? extends AdvancedRobot { private double lastEnergy, direction;
public final void run() {
lastEnergy = 100.0 * (direction = 1.0);
setTurnRadarRight(Double.POSITIVE_INFINITY);
}
public final void onScannedRobot(ScannedRobotEvent event) {
setAhead((lastEnergy != (lastEnergy = event.getEnergy()) && event.getEnergy() - lastEnergy <= 3.0) ? 100 * (direction *= -1) : getGetDistanceRemaining());
setTurnRight?((event.getBearing() - 90) - (getVelocity() / Math.abs(getVelocity())) * ((300 - event.getDistance()) / 300) * 45);
setTurnRadarLeft(getRadarTurnRemaining?());
}
}
-- nano
public class Pacifist extends Robot {
public void run() {
turnLeft(getHeading());
while (true)
{
ahead(Double.POSITIVE_INFINITY);
turnRight(90);
}
}
}
And while I'm at it, here's a much shorter version of nano's bot
public class ConscientiousObjector? extends AdvancedRobot{
double lastEnergy, direction;
public final void run() {
direction = 1.0;
setTurnRadarRight(Double.POSITIVE_INFINITY);
}
public final void onScannedRobot(ScannedRobotEvent e) {
if (lastEnergy != (lastEnergy = e.getEnergy())) setAhead(100 * (direction *= -1)); setTurnRight?((e.getBearing() - 90) - (getVelocity()) * ((300 - e.getDistance()) / 300) * 5); } }
public class Merry extends Robot {
public void run() {
do {
ahead(400);
back(400);
} while (true);
}
}
-- nano
I'd say 800x600 - and not just out-survive MyFirstRobot, but also out-score him without firing (I haven't tested Merry to see if it does this) -- Kawigi
If Merry outscores MyFirstRobot I will eat my PowerBook. =) Besides, Merry can be shrinked. -- PEZ
In terms of lines or codesize? -- Kawigi
Codesize. It was you who told me that "do { ... } while(true)" is shorter. =) -- PEZ
Well, MovesWithWind? currently outscores MyFirstRobot by a huge margin. ;) -- nano
What about just removing the fire line from HaikuRamFire, does that count? -- Kuuran
Does it work? -- Kawigi
Nope - that will get HaikuRamFire killed. He doesn't dodge well enough to survive.
public class Foo extends AdvancedRobot {
public void run()
{
turnRadarRight(Double.POSITIVE_INFINITY);
}
public void onScannedRobot(ScannedRobotEvent e)
{
setTurnRight(e.getBearing() + 50);
setAhead(200);
}
}
This guy does win pretty well - :) -- Miked0801
Hrm, I thought HaikuRamFire might win on account of bonus ram points, oh well. -- Kuuran
The problem is MyFirstRobot hits him a couple of times while he's closing. That means he'll never win a match on ram damage. Foo does get occasional ram damage, but because he dodges in a fairly elliptic pattern, he almost never gets hit. Code size could probably be reduced a byte or two more if I cared, but I think he's good enough. -- Miked0801
I just stumbled on this page... here's mine:
// Perceptual Haiku Nano Robot Droid
public class PHNRD extends Robot implements Droid {
public void run() {
while(true) {
ahead(252);
ahead(-252);
}
}
public void onHitByBullet(HitByBulletEvent event) {
ahead(Math.random() > .5 ? 48 : -48);
turnRight(event.getBearing() - 180 * Math.floor(event.getBearing() / 180) - 90);
}
}
I have only tested it on a 1000x1000 field but I don't think it can be much worse on 800x600. -- Jonathan
In case anyone is interested, I made Merry smaller :-p -- AaronKrill
public class MiniMerry extends Robot {
public void run() {
ahead(400);
back(400);
run();
}
}
ooo, now thats clever. Never thought about doing loops via recursion... -- Jokester
I can outscore MyFirstRobot with this Haikubot... although, not by much. -- AaronKrill
package amk;
import robocode.*;
public class DodgyPoet extends AdvancedRobot
{
double energy = 100;
public void run() {
while(true) { setTurnRadarRight(Double.POSITIVE_INFINITY);
ahead(Double.POSITIVE_INFINITY); }
}
public void onScannedRobot(ScannedRobotEvent e) {
setTurnRight((e.getBearing()) + (((e.getBearing() <= -90)?1:1)*180) + (((e.getBearing() > 90)?1:1)*-180)+(((1 <= (e.getEnergy() - energy)) & ((e.getEnergy() - energy <= 3)))?1:1)*25+(energy = e.getEnergy())-e.getEnergy());
}
}
800x600:
1st: jonathan.PHNRD 59178 49200 9840 0 0 138 0 984 16 0 2nd: sample.MyFirstRobot 7061 800 160 5650 383 67 0 16 984 01000x1000:
1st: jonathan.PHNRD 59714 49700 9940 0 0 74 0 994 6 0 2nd: sample.MyFirstRobot 4296 300 60 3768 144 23 0 6 994 0-- Jonathan
Here is a Perceptual Couplet Robot Droid to do the job:
package bayen;
import robocode.*;
/**
* CoupletUba - a robot by Bayen
*/
public class CoupletUba extends Robot implements Droid {
/**
* First Line - Go forward
*/
public void run() {while(true)ahead(5000);}
/**
* Second Line - Follow the Walls
*/
public void onHitWall(HitWallEvent e) {turnRight(e.getBearing()+90);}
}
If you wanted to make it better, you could add:
/**
* Third Line - Move from Bullets
*/
public void onHitByBullet(HitByBulletEvent e) {turnRight(90);}
/**
* Fourth Line - Move from Enemies
*/
public void onHitRobot(HitRobotEvent e) {turnRight(90);}
--Bayen
public class MovesWithWind? extends AdvancedRobot {
private double lastEnergy=100.0, direction=1.0;
public final void run() {
setTurnRadarRight(Double.POSITIVE_INFINITY);
}
public final void onScannedRobot?(ScannedRobotEvent event) {
setAhead((lastEnergy != (lastEnergy = event.getEnergy()) && event.getEnergy() - lastEnergy <= 3.0) ? 100 * (direction *= -1) : getGetDistanceRemaining());
setTurnRight((event.getBearing() - 90) - (getVelocity() / Math.abs(getVelocity())) * ((300 - event.getDistance()) / 300) * 45);
//setTurnRadarLeft(getRadarTurnRemaining());
}
}
With a radar with more slip-rate and assigning variables on the same line as declaring them. -- Nfwu