@@ -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> |
@@ -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 '^'; | |||
} | |||
} |
@@ -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); |
@@ -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 '^'; | |||
} | |||
} | |||
} |