|
|
|
|
|
|
|
|
nextMove = stoneDetected && !ignoreStone ? goToStone(view) : walkBySpiral(); |
|
|
nextMove = stoneDetected && !ignoreStone ? goToStone(view) : walkBySpiral(); |
|
|
|
|
|
|
|
|
if(nextMove == '^' && view.data.charAt(7) == '*'){ |
|
|
if(nextMove == '^' && view.data.charAt(7) == '*'){ |
|
|
Random random = new Random(); |
|
|
|
|
|
nextMove = (random.nextInt(2) % 2 == 0) ? '<' : '>'; |
|
|
|
|
|
|
|
|
nextMove = (countCollectedStonesLeft(view) <= countCollectedStonesRight(view)) ? '<' : '>'; |
|
|
ignoreStone = true; |
|
|
ignoreStone = true; |
|
|
} |
|
|
} |
|
|
if(countCollectedStones(view) <= 2) ignoreStone = false; |
|
|
if(countCollectedStones(view) <= 2) ignoreStone = false; |
|
|
return nextMove; |
|
|
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) { |
|
|
|
|
|
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) { |
|
|
|
|
|
if(view.data.charAt(stone) == '*'){ |
|
|
|
|
|
stones++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return stones; |
|
|
|
|
|
} |
|
|
private int countCollectedStones(View view) { |
|
|
private int countCollectedStones(View view) { |
|
|
int count = 0; |
|
|
int count = 0; |
|
|
|
|
|
|