Difference between revisions of "Talk:SavantVS"
(sorry, confused WS with VS =)) |
(SavantVS Source) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 8: | Line 8: | ||
Sorry, I confused this robot from SavantWS, you should name your robot more explicitly. » <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> » 10:46, 30 July 2009 (UTC) | Sorry, I confused this robot from SavantWS, you should name your robot more explicitly. » <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> » 10:46, 30 July 2009 (UTC) | ||
| + | |||
| + | I cant find the source code for SavantVS. Could you post it up somewhere? --[[User:Khanguy|Khanguy]] 05:10, 27 May 2011 (UTC) | ||
| + | |||
| + | Hmm, it looks like the repository is still down. Here's the source: | ||
| + | <pre>package oog.rumble; | ||
| + | |||
| + | import robocode.*; | ||
| + | import robocode.util.Utils; | ||
| + | |||
| + | public class SavantVS extends AdvancedRobot { | ||
| + | final static String distances=""+(char)-120+(char)-80+(char)-40+(char)-0+(char)40+(char)80+(char)120; | ||
| + | |||
| + | static double hits[][]=new double[7][17]; | ||
| + | static double oldEnergy; | ||
| + | static int move; | ||
| + | static int dir; | ||
| + | static int startVel; | ||
| + | public void run(){ | ||
| + | dir=1; | ||
| + | setTurnRadarRightRadians(Double.POSITIVE_INFINITY); | ||
| + | } | ||
| + | public void onScannedRobot(ScannedRobotEvent e){ | ||
| + | double absBearing=1000000000; | ||
| + | if(oldEnergy>(oldEnergy=e.getEnergy())){ | ||
| + | startVel=8+(int)getVelocity(); | ||
| + | for(int i=0;i<7;i++){ | ||
| + | if(hits[i][startVel]<absBearing){ | ||
| + | |||
| + | setAhead((short)distances.charAt(move=i)*dir); | ||
| + | absBearing=hits[i][startVel]; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | setTurnLeftRadians(Math.cos(absBearing=e.getBearingRadians())); | ||
| + | setTurnRadarLeftRadians(getRadarTurnRemainingRadians()); | ||
| + | setTurnGunRightRadians(Utils.normalRelativeAngle((absBearing+=getHeadingRadians())-getGunHeadingRadians())+(e.getVelocity()*Math.sin(e.getHeadingRadians()-absBearing))/16); | ||
| + | setFire(2.5); | ||
| + | } | ||
| + | public void onHitByBullet(HitByBulletEvent e){ | ||
| + | for(int i=0;i<7;i++){ | ||
| + | hits[i][startVel]+=i==move?2:1.0/Math.abs(i-move); | ||
| + | } | ||
| + | } | ||
| + | public void onHitWall(HitWallEvent e){ | ||
| + | dir=-dir; | ||
| + | } | ||
| + | }</pre> | ||
| + | --[[User:CrazyBassoonist|CrazyBassoonist]] 13:00, 27 May 2011 (UTC) | ||
Latest revision as of 14:00, 27 May 2011
Sounds like this bot will crush LittleBlackBook, even after my next update with tuning values specifically for new bots. My bot will only fire in 1 zone per 160 pixel unit area so unless you drift around alot in distance, I have no chance. :) --Miked0801 01:29, 17 June 2009 (UTC)
Sorry, but you seem to be right:-) It gets 78% against lbb; PBI of +48.5--CrazyBassoonist 01:34, 17 June 2009 (UTC)
- No worries, my next release has the cannot hit stop'n'go issue fixed. That'll more than make up for a few beat downs along the way :) --Miked0801 02:35, 17 June 2009 (UTC)
Source Code
I didn't see any source code attached and you said it is RWPCL. Is this your IDE fault? » Nat | Talk » 08:46, 30 July 2009 (UTC)
Sorry, I confused this robot from SavantWS, you should name your robot more explicitly. » Nat | Talk » 10:46, 30 July 2009 (UTC)
I cant find the source code for SavantVS. Could you post it up somewhere? --Khanguy 05:10, 27 May 2011 (UTC)
Hmm, it looks like the repository is still down. Here's the source:
package oog.rumble;
import robocode.*;
import robocode.util.Utils;
public class SavantVS extends AdvancedRobot {
final static String distances=""+(char)-120+(char)-80+(char)-40+(char)-0+(char)40+(char)80+(char)120;
static double hits[][]=new double[7][17];
static double oldEnergy;
static int move;
static int dir;
static int startVel;
public void run(){
dir=1;
setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
}
public void onScannedRobot(ScannedRobotEvent e){
double absBearing=1000000000;
if(oldEnergy>(oldEnergy=e.getEnergy())){
startVel=8+(int)getVelocity();
for(int i=0;i<7;i++){
if(hits[i][startVel]<absBearing){
setAhead((short)distances.charAt(move=i)*dir);
absBearing=hits[i][startVel];
}
}
}
setTurnLeftRadians(Math.cos(absBearing=e.getBearingRadians()));
setTurnRadarLeftRadians(getRadarTurnRemainingRadians());
setTurnGunRightRadians(Utils.normalRelativeAngle((absBearing+=getHeadingRadians())-getGunHeadingRadians())+(e.getVelocity()*Math.sin(e.getHeadingRadians()-absBearing))/16);
setFire(2.5);
}
public void onHitByBullet(HitByBulletEvent e){
for(int i=0;i<7;i++){
hits[i][startVel]+=i==move?2:1.0/Math.abs(i-move);
}
}
public void onHitWall(HitWallEvent e){
dir=-dir;
}
}
--CrazyBassoonist 13:00, 27 May 2011 (UTC)