Browse Source

Dateien hochladen nach „“

master
Orlando Boyny 9 months ago
parent
commit
817cd1679b
2 changed files with 125 additions and 0 deletions
  1. 62
    0
      SnakeBot.java
  2. 63
    0
      battleBot.java

+ 62
- 0
SnakeBot.java View File

@@ -0,0 +1,62 @@
package Prak1;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.InetSocketAddress;
public class SnakeBot extends Bot {
private int steps = 1;
private int counter = 0;
private char lastCommand = '^';
private int zuGehen = 1;
private int gegangen = 0;
boolean amDrehen = false;
boolean amGehen = true;
int x =0;
public SnakeBot(String[] args) {
super(args);
}
@Override
protected char nextMove(View view) {
char command;
if(x<4){
if(amGehen && gegangen < zuGehen){
gegangen +=1;
return '^';
}else{
x += 1;
gegangen =0;
return '>';
}
}
else{
x=0;
zuGehen +=2;
gegangen =0;
return '^';
}
}
private char drehen() {
return 'd';
}
private char gehen() {
return 'w';
}
public static void main(String[] args) {
new SnakeBot(args).run();
}
}

+ 63
- 0
battleBot.java View File

@@ -0,0 +1,63 @@
package Prak1;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.InetSocketAddress;
public class battleBot extends Bot {
private int steps = 1;
private int counter = 0;
private char lastCommand = '^';
private int zuGehen = 1;
private int gegangen = 0;
boolean amDrehen = false;
boolean amGehen = true;
int x =0;
public battleBot(String[] args) {
super(args);
}
@Override
protected char nextMove(View view) {
char command;
if(x<4){
if(amGehen && gegangen < zuGehen){
gegangen +=1;
return '^';
}else{
x += 1;
gegangen =0;
return '>';
}
}
else{
x=0;
zuGehen +=2;
gegangen =0;
return 'f';
}
}
private char drehen() {
return 'd';
}
private char gehen() {
return 'w';
}
public static void main(String[] args) {
new battleBot(args).run();
}
}

Loading…
Cancel
Save