Wall-E/src/Praktikum05/RumbleBot.java

45 lines
972 B
Java
Raw Normal View History

2024-02-06 19:49:31 +00:00
package Praktikum05;
2024-02-07 12:44:14 +00:00
import java.util.Random;
2024-02-06 19:49:31 +00:00
import java.util.Scanner;
2024-02-07 12:44:14 +00:00
public class RumbleBot extends Bot {
2024-02-06 19:49:31 +00:00
protected RumbleBot(String[] args) {
super(args);
}
private Scanner input = new Scanner(System.in);
2024-02-07 12:44:14 +00:00
private int counter = 0;
private Random leftOrRight = new Random();
2024-02-06 19:49:31 +00:00
@Override
protected char nextMove(View view) throws Exception {
char roverKennung = view.data.charAt(40);
boolean exit = false;
while (!exit) {
2024-02-07 12:44:14 +00:00
if(counter <= 8){
counter++;
return '^';
}else if(counter > 8){
counter = 0;
if(leftOrRight.nextBoolean()){
return '>';
}else{
return '<';
}
}
2024-02-06 19:49:31 +00:00
}
throw new Exception("Beendet");
}
public static void main(String args[]){
Bot bot = new RumbleBot(args);
bot.run();
}
2024-02-07 12:44:14 +00:00
2024-02-06 19:49:31 +00:00
}