|
|
@ -279,6 +279,12 @@ public class AIGridGUI extends JPanel { |
|
|
|
} |
|
|
|
left.setCell(l); |
|
|
|
left.setCount(leftCount); |
|
|
|
|
|
|
|
//Determine which direction had the most consecutive hits and try to continue in that direction. |
|
|
|
|
|
|
|
DirectionCompare dc = new DirectionCompare(); |
|
|
|
Collections.sort(directions, dc); |
|
|
|
guessLocation = directions.get(0).getCell(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -320,4 +326,11 @@ public class AIGridGUI extends JPanel { |
|
|
|
return dirLeft; |
|
|
|
} |
|
|
|
} |
|
|
|
//Implement comparator to compare directions. |
|
|
|
|
|
|
|
class DirectionCompare implements Comparator<Direction> { |
|
|
|
public int compare(Direction one, Direction two) { |
|
|
|
return ((Integer) two.getCount()).compareTo((Integer) one.getCount()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |