1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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();
- }
- }
|