Team
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SnakeBot.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package Prak1;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. import java.io.IOException;
  5. import java.io.OutputStream;
  6. import java.net.Socket;
  7. import java.net.InetSocketAddress;
  8. public class SnakeBot extends Bot {
  9. private int steps = 1;
  10. private int counter = 0;
  11. private char lastCommand = '^';
  12. private int zuGehen = 1;
  13. private int gegangen = 0;
  14. boolean amDrehen = false;
  15. boolean amGehen = true;
  16. int x =0;
  17. public SnakeBot(String[] args) {
  18. super(args);
  19. }
  20. @Override
  21. protected char nextMove(View view) {
  22. char command;
  23. if(x<4){
  24. if(amGehen && gegangen < zuGehen){
  25. gegangen +=1;
  26. return '^';
  27. }else{
  28. x += 1;
  29. gegangen =0;
  30. return '>';
  31. }
  32. }
  33. else{
  34. x=0;
  35. zuGehen +=2;
  36. gegangen =0;
  37. return '^';
  38. }
  39. }
  40. private char drehen() {
  41. return 'd';
  42. }
  43. private char gehen() {
  44. return 'w';
  45. }
  46. public static void main(String[] args) {
  47. new SnakeBot(args).run();
  48. }
  49. }