<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<project version="4"> | <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" /> | <output url="file://$PROJECT_DIR$/out" /> | ||||
</component> | </component> | ||||
</project> | </project> |
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 '^'; | |||||
} | |||||
} |
boolean foundShip = false; | boolean foundShip = false; | ||||
boolean offByOne = true; | boolean offByOne = true; | ||||
int currentStepCount = 0; | int currentStepCount = 0; | ||||
int steps = 10; | |||||
int steps = 0; | |||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
Bot bot = new EscapeBot(args); | Bot bot = new EscapeBot(args); |
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 '^'; | |||||
} | |||||
} | |||||
} |