48 lines
931 B
Java
48 lines
931 B
Java
|
|
public class SnakeBot extends Bot {
|
|
|
|
int steps = 0;
|
|
int counter = 0;
|
|
public SnakeBot(String [] args) {
|
|
super(args);
|
|
}
|
|
public char found (View view) throws Exception{
|
|
|
|
boolean field = view.data.contains("@");
|
|
|
|
if(field){
|
|
counter++;
|
|
}
|
|
if(counter % 3 == 0){
|
|
return '<';
|
|
} else {
|
|
return '^';
|
|
}
|
|
}
|
|
@Override
|
|
public char nextMove(View view) throws Exception {
|
|
steps++;
|
|
if(view.data.contains("o")) {
|
|
return found(view);
|
|
}
|
|
if(steps == 1){
|
|
return '<';
|
|
} else if(steps == 5){
|
|
return '>';
|
|
} else if(steps == 32){
|
|
steps = 0;
|
|
return '^';
|
|
}else{
|
|
return '^';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
SnakeBot bot = new SnakeBot(args);
|
|
bot.run();
|
|
}
|
|
|
|
|
|
} |