# Chase-san/Free Code

Robo Home | Chase-san | Changes | Preferences | AllPages

Difference (from prior major revision) (no other diffs)

 * All this code is fairly ancient, if you want to use it feel free. My improved DrawingBot makes your robot into a slow bot, it embends an static image in the main class which is just blitted to the battlefield on draw... meanin you can draw to it anywhere with the normal drawing tools(just be sure to erase it). If you want some of my more interesting stuff look in http://www.csdgn.org/code/robocode/chase/s2/, the Extension.java should be interesting, as it holds the basic stuff I use for drawing al la the mirrored graphics system. --Chase

Inspired by David Alves/Free Code

Here is a 2D range based data structure: Chase-san/RangeBucket2D

Most of these are just math I threw togeather to help me out.

BellCurve?: Something I whipped up when messing around with a better way to smooth data.
```	/**
* Bell curve smoother... also know as gaussian smooth or normal distrabution
* @param x Current Position
* @param w Width (number of binIndexes)
* @return value of a bellcurve
*/
public static final double smoothingModifier = 30.0;
public static double bellcurve(int x, int c, int w) {
int diff = (int)Math.abs(c - x);
double binsmooth = smoothingModifier/w;

//I suppose technically you could also use Math.exp(-(binsmooth*binsmooth*diff*diff)/2.0);
return Math.pow(Math.E, -(binsmooth*binsmooth*diff*diff)/2.0);
}
```

RobotState?: Not the most useless or useful class, I find it useful as its not a all incompassing class, so your not wasting space on data you don't need. Could very easily be used in a pattern matcher.
```package chase.g;
import robocode.ScannedRobotEvent;
public class RobotState {
public double x, xDelta;
public double y, yDelta;
public double distance, distanceDelta;
public double bearing, bearingDelta;
public double velocity, velocityDelta;
public double latVelocity, latVelocityDelta;

public void setRobotState(AdvancedRobot b, ScannedRobotEvent e) {
x = b.getX();
y = b.getY();
distance = e.getDistance();
velocity = b.getVelocity();
}
public void setEnemyState(AdvancedRobot b, ScannedRobotEvent e) {
distance = e.getDistance();
x = b.getX() + Math.sin(bearing) * distance;
y = b.getY() + Math.cos(bearing) * distance;
velocity = e.getVelocity();
bearing += Math.PI; //bearing from the enemy to us of course
}
public void setDelta(RobotState rs) {
xDelta = x - rs.x;
yDelta = y - rs.y;
distanceDelta = distance - rs.distance;
bearingDelta = bearing - rs.bearing;
velocityDelta = velocity - rs.velocity;
latVelocityDelta = latVelocity - rs.latVelocity;
}
}
```

Comments: I also made what I would like to consider a better version of David Alves/DrawingBot, but unless people want it I wont release it.

It works more like Graphics2D does, it can draw, fill and stroke shapes and draw points. It even has a method that will draw a image from the data folder to the screen. Its also smaller then DrawingBot, but thats because it uses the built-in Shape method.

Your bell curve smoother, why does it take doubles as arguments? Shouldn't it take ints? -- Skilgannon

• Ahh good point, it should indeed! I typed this out, I didn't copy and paste it. Fixed. --Chase-san

I would definatly like to see how you improved DrawingBot, i made some update for yoda aswell, storing Renerables in a stack and poping them off when drawing, still not a fast as i would like. -- Gorded

• I have a interesting system for that actually, it stores it all in a queue in the main bot, but passes that reference statically to an accessory class which is extended by the gun, movement, and whatever else I care to have (normally nothing). It uses a Renderable framework I made up for it, it works more like the native Graphics class then David's, meanin you have to individually set the color, and you can set linestyle, but it does not directly use the Graphics or Graphics2D Class. But now that I think about it, if it did I could of saved myself alot of code, but it might not be very feasible. --Chase-san

I'd like to see your improved DrawingBot, to compare to mine! One more thing, does you robot state class above right? I think the LatVel? and AdvVel? is wrong. --Nat

• All this code is fairly ancient, if you want to use it feel free. My improved DrawingBot makes your robot into a slow bot, it embends an static image in the main class which is just blitted to the battlefield on draw... meanin you can draw to it anywhere with the normal drawing tools(just be sure to erase it). If you want some of my more interesting stuff look in http://www.csdgn.org/code/robocode/chase/s2/, the Extension.java should be interesting, as it holds the basic stuff I use for drawing al la the mirrored graphics system. --Chase

Robo Home | Chase-san | Changes | Preferences | AllPages