RumbleBot Implementierung
This commit is contained in:
parent
e4483c8064
commit
65e40b85ea
46
RumbleBot.java
Normal file
46
RumbleBot.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
public class RumbleBot extends Bot {
|
||||||
|
|
||||||
|
int steps = 0;
|
||||||
|
int counter = 0;
|
||||||
|
public RumbleBot(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) {
|
||||||
|
RumbleBot bot = new RumbleBot(args);
|
||||||
|
bot.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,49 +1,48 @@
|
|||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class SnakeBot extends Bot {
|
public class SnakeBot extends Bot {
|
||||||
|
|
||||||
// int rounds = ;
|
int steps = 0;
|
||||||
int steps = 1;
|
int counter = 0;
|
||||||
public SnakeBot(String [] args) {
|
public SnakeBot(String [] args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
|
public char found (View view) throws Exception{
|
||||||
|
|
||||||
@Override
|
boolean field = view.data.contains("@");
|
||||||
public char nextMove(View view) throws Exception {
|
|
||||||
|
|
||||||
rounds++;
|
if(field){
|
||||||
|
counter++;
|
||||||
switch(rounds){
|
|
||||||
case 3:
|
|
||||||
rounds = 0;
|
|
||||||
move(steps);
|
|
||||||
steps++;
|
|
||||||
return '<';
|
|
||||||
default:
|
|
||||||
move(steps);
|
|
||||||
steps++;
|
|
||||||
}
|
}
|
||||||
return 0;
|
if(counter % 3 == 0){
|
||||||
|
return '<';
|
||||||
}
|
} else {
|
||||||
|
|
||||||
public char move(int s){
|
|
||||||
for(int i = 0; i < s; i++){
|
|
||||||
return '^';
|
return '^';
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@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) {
|
public static void main(String[] args) {
|
||||||
SnakeBot bot = new SnakeBot(args);
|
SnakeBot bot = new SnakeBot(args);
|
||||||
bot.run();
|
bot.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user