私はRobocodeロボットについて尋ねました。私は自分のロボットのコードを持っていて、私の友達のうち26人が11番になった。しかし、私はそれをより良くしようとします。私はウェブサイトを見て、コードを調整して予測不能に動くようにしました。これは10ラウンドで1回1位になりました。このロボットの改善に役立つアイデアやヒントを教えてください。私は自分のロボットを編集して、それがどのようになるか見ることができます。私はロボットが拡張ロボットに残ることを望む。あなたを助ける必要があります -Robocodeのロボットを作るための助けが必要
package aaa;
import robocode.*;
//import java.awt.Color;
// API help: http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
/**
*Epictron - a robot by ASHAR ASLAM!!!
*/
public class Epictron extends Robot
{
/**
* run: Epictron's default behavior
*/
public void run() {
// Initialization of the robot should be put here
// After trying out your robot, try uncommenting the import at the top,
// and the next line:
// setColors(Color.blue,Color.blue,Color.grey,Color.red,Color.green); // body,gun,radar
// Robot main loop
while(true) {
// Replace the next 4 lines with any behavior you would like
double distance = Math.random()*300;
double angle = Math.random()*45;
turnRight(angle);
ahead(distance);
ahead(100);
turnGunRight(90);
back(100);
turnGunRight(90);
}
}
/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
// Replace the next line with any behavior you would like
double distance = e.getDistance();
if(distance<200)
{
fire(3.5);
}
else if(distance<500)
{
fire(2.5);
}
else if(distance<800)
{
fire(1.5);
}
else
{
fire(0.5);
}
}
/**
* onHitByBullet: What to do when you're hit by a bullet
*/
public void onHitByBullet(HitByBulletEvent e) {
// Replace the next line with any behavior you would like
back(10);
}
/**
* onHitWall: What to do when you hit a wall
*/
public void onHitWall(HitWallEvent e) {
// Replace the next line with any behavior you would like
back(20);
}
}
はたぶん、いくつかの戦略を考案してみてください。他のロボットを追うように。または逃げる。または、最後まで角を隠すだけです...もっと多くを発明し、ランダムに何をするかを決めることができます。 – bdecaf
私はrobocodeに新しいが、私は弾丸の最大の火力は3だからあなたが使用している3.5は有効ではないと信じている – Yiannis