Browse Source

SankeBot

master
Your Average Code 11 months ago
parent
commit
94f5f2bceb
4 changed files with 55 additions and 19 deletions
  1. 1
    1
      .idea/misc.xml
  2. 0
    17
      src/AutomaticBot.java
  3. 1
    1
      src/EscapeBot.java
  4. 53
    0
      src/SnakeBot.java

+ 1
- 1
.idea/misc.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

+ 0
- 17
src/AutomaticBot.java View File

@@ -1,17 +0,0 @@
public class AutomaticBot extends Bot {

public static void main(String[] args) {
Bot bot = new AutomaticBot(args);
bot.run();
}

protected AutomaticBot(String[] args) {
super(args);
}

@Override
protected char nextMove(View view) throws Exception {
System.out.println("fagh");
return '^';
}
}

+ 1
- 1
src/EscapeBot.java View File

@@ -3,7 +3,7 @@ public class EscapeBot extends Bot {
boolean foundShip = false;
boolean offByOne = true;
int currentStepCount = 0;
int steps = 10;
int steps = 0;

public static void main(String[] args) {
Bot bot = new EscapeBot(args);

+ 53
- 0
src/SnakeBot.java View File

@@ -0,0 +1,53 @@
public class SnakeBot extends Bot {

boolean foundShip = false;
boolean offByOne = true;
int currentStepCount = 0;
int steps = 0;

public static void main(String[] args) {
Bot bot = new SnakeBot(args);
bot.run();
}

protected SnakeBot(String[] args) {
super(args);
}

@Override
protected char nextMove(View view) throws Exception {
String data = view.data;
System.out.println();

if (data.contains("@")) {
int index = data.indexOf('@');
if (index < view.width * 2 && !(index > view.width * 3)) {
return safeMove(data);
} else if (index % 5 < 2) {
return '<';
} else if (index % 5 > 2) {
return '>';
}
return ' ';
} else if (steps == 0) {
currentStepCount += 1;
if (offByOne) {
currentStepCount += 1;
}
offByOne = !offByOne;
steps = currentStepCount;
return '>';
} else {
steps -= 1;
return safeMove(data);
}
}

protected char safeMove(String data) {
if (data.charAt(7) == '*') {
return '>';
} else {
return '^';
}
}
}

Loading…
Cancel
Save