Adjusted text formatting
This commit is contained in:
parent
eb4a1028f9
commit
82ab1e9717
@ -8,6 +8,7 @@ public class EscapeBot extends Bot{
|
||||
Bot escapeBot = new EscapeBot(args);
|
||||
escapeBot.run();
|
||||
}
|
||||
|
||||
protected EscapeBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
@ -15,10 +16,12 @@ public class EscapeBot extends Bot{
|
||||
boolean rocketDetected = view.data.contains("o");
|
||||
return rocketDetected ? goToRocket(view) : walkBySpiral();
|
||||
}
|
||||
|
||||
private char goToRocket(View view){
|
||||
int rowDifference = findRocketRow(view) - 2;
|
||||
return rowDifference < 0 ? '^' : '<';
|
||||
}
|
||||
|
||||
private int findRocketRow(View view) {
|
||||
return view.data.indexOf('o') / 5;
|
||||
}
|
||||
@ -32,6 +35,7 @@ public class EscapeBot extends Bot{
|
||||
moves = moves.substring(1);
|
||||
return nextMove;
|
||||
}
|
||||
|
||||
private char walkByCircles(){
|
||||
if (moves.isEmpty()) {
|
||||
circleNumber++;
|
||||
@ -48,6 +52,7 @@ public class EscapeBot extends Bot{
|
||||
moves = moves.substring(1);
|
||||
return nextMove;
|
||||
}
|
||||
|
||||
private char walkBySpiral(){
|
||||
if (moves.isEmpty()) {
|
||||
spiralNumber++;
|
||||
@ -57,4 +62,5 @@ public class EscapeBot extends Bot{
|
||||
moves = moves.substring(1);
|
||||
return nextMove;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ public class ManualBot extends Bot{
|
||||
Bot manualBot = new ManualBot(args);
|
||||
manualBot.run();
|
||||
}
|
||||
|
||||
protected ManualBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
@ -3,9 +3,11 @@ public class RumbleBot extends Bot{
|
||||
Bot rumbleBot = new RumbleBot(args);
|
||||
rumbleBot.run();
|
||||
}
|
||||
|
||||
protected RumbleBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
protected char nextMove(View view){
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import java.util.Random;
|
||||
|
||||
public class SnakeBot extends Bot{
|
||||
String moves = "";
|
||||
private boolean goesForward = true;
|
||||
@ -10,6 +8,7 @@ public class SnakeBot extends Bot{
|
||||
Bot snakeBot = new SnakeBot(args);
|
||||
snakeBot.run();
|
||||
}
|
||||
|
||||
protected SnakeBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
@ -17,7 +16,7 @@ public class SnakeBot extends Bot{
|
||||
protected char nextMove(View view){
|
||||
boolean stoneDetected = view.data.contains("@");
|
||||
char nextMove;
|
||||
nextMove = stoneDetected && !ignoreStone ? goToStone(view) : walkBySpiral();
|
||||
nextMove = (stoneDetected && !ignoreStone) ? goToStone(view) : walkBySpiral();
|
||||
|
||||
if(nextMove == '^' && view.data.charAt(7) == '*'){
|
||||
nextMove = (countCollectedStonesLeft(view) <= countCollectedStonesRight(view)) ? '<' : '>';
|
||||
@ -26,26 +25,29 @@ public class SnakeBot extends Bot{
|
||||
if(countCollectedStones(view) <= 2) ignoreStone = false;
|
||||
return nextMove;
|
||||
}
|
||||
|
||||
private int countCollectedStonesLeft(View view) {
|
||||
int[] leftStones = {0, 1, 5, 6, 10, 11, 15, 16, 20, 21};
|
||||
int stones = 0;
|
||||
for (int stone: leftStones) {
|
||||
for (int stone : leftStones) {
|
||||
if(view.data.charAt(stone) == '*'){
|
||||
stones++;
|
||||
}
|
||||
}
|
||||
return stones;
|
||||
}
|
||||
|
||||
private int countCollectedStonesRight(View view) {
|
||||
int[] rightStones = {3, 4, 8, 9, 13, 14, 18, 19, 23, 24};
|
||||
int stones = 0;
|
||||
for (int stone: rightStones) {
|
||||
for (int stone : rightStones) {
|
||||
if(view.data.charAt(stone) == '*'){
|
||||
stones++;
|
||||
}
|
||||
}
|
||||
return stones;
|
||||
}
|
||||
|
||||
private int countCollectedStones(View view) {
|
||||
int count = 0;
|
||||
|
||||
@ -56,6 +58,7 @@ public class SnakeBot extends Bot{
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private char goToStone(View view){
|
||||
int rowDifference = findStoneRow(view) - 2;
|
||||
return rowDifference < 0 ? '^' : '<';
|
||||
@ -64,6 +67,7 @@ public class SnakeBot extends Bot{
|
||||
private int findStoneRow(View view) {
|
||||
return view.data.indexOf('@') / 5;
|
||||
}
|
||||
|
||||
private char walkByColumns() {
|
||||
if(moves.isEmpty()){
|
||||
moves = "^".repeat(28);
|
||||
@ -74,6 +78,7 @@ public class SnakeBot extends Bot{
|
||||
moves = moves.substring(1);
|
||||
return nextMove;
|
||||
}
|
||||
|
||||
private char walkByCircles(){
|
||||
if (moves.isEmpty()) {
|
||||
circleNumber++;
|
||||
@ -90,6 +95,7 @@ public class SnakeBot extends Bot{
|
||||
moves = moves.substring(1);
|
||||
return nextMove;
|
||||
}
|
||||
|
||||
private char walkBySpiral(){
|
||||
if (moves.isEmpty()) {
|
||||
spiralNumber++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user