前提・実現したいこと
車を自動で動かし、旗を取ってポイントを稼ぐプログラミングで、10000回試行し、平均15以上のスコアを取得したいのですが、私のアイデアでは10が限界でそれ以上いけません。解決策をもらいたいです。
該当のソースコード
Java
package simplerace.x;
import simplerace.*;
public class AI implements Controller, Constants {
public void reset() {}
public int control (SensorModel inputs) {
int command = 0;
double speed = inputs.getSpeed();
double angle = inputs.getAngleToNextWaypoint();
double carPosi = Math.sqrt( Math.pow(inputs.getPosition().x,2.0) + Math.pow(inputs.getPosition().y,2.0) );
double tarPosi = Math.sqrt( Math.pow(inputs.getNextWaypointPosition().x,2.0) + Math.pow(inputs.getNextWaypointPosition().y,2.0) );
double tardis = Math.sqrt(Math.pow((inputs.getNextNextWaypointPosition().x - inputs.getNextWaypointPosition().x),2.0) + Math.pow((inputs.getNextNextWaypointPosition().y - inputs.getNextWaypointPosition().y) , 2.0));
double carX = inputs.getPosition().x;
double carY = inputs.getPosition().y;
double distance = inputs.getDistanceToNextWaypoint();
//Double v = Math.sqrt(Math.pow(inputs.getVelocity().x , 2.0) + Math.pow(inputs.getVelocity().y , 2.0));//車の速度を計算する
if(angle>0){//目標との角度が0以上なら旗が正面より左、ハンドルを左に切りながらアクセル command = 6;
}else{//それ以外なら右に切りながらアクセル
command = 8;
}
if(speed >= 6.5){
command = 1;
//System.out.println(speed);
}
if(tardis < 100 && speed >= 3 && distance <= 0.5){
command = 1;
}
//System.out.println(speed);
return command;
}
}
別のファイルにcommandの値を渡すことで、車を動かします。
commandの値は
1ブレーキ
3ハンドルを左に切る
4何もしない
5ハンドルを右に切る
6左に切りながらアクセル
7アクセル
8右に切りながらアクセル
あなたの回答
tips
プレビュー