Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void prioritizeLocations(List<Location> unsorted, PirateGame game, Pirate pirate) {
- int[] values = new int[unsorted.size()];
- int minDist; //Minimum distance
- int currentDist; //Temporary variable
- for (int i = 0; i < unsorted.size(); i++) {
- minDist = Integer.MAX_VALUE;
- for (Pirate enemy : game.enemySoberPirates()) {
- currentDist = game.distance(enemy, unsorted.get(i));
- if (currentDist < minDist)
- minDist = currentDist;
- }
- values[i] = minDist; //Rating a location by the distance from the closest enemy ship
- }
- quickSort(values, 0, values.length - 1, unsorted); //Sorts safe first
- boolean treasure = pirate.hasTreasure();
- if (treasure)
- game.debug("We have a treasure, ID: " + pirate.getId());
- boolean booze = pirate.getReloadTurns() <= 0;
- if (booze)
- game.debug("We have booze, ID: " + pirate.getId());
- if ((!pirate.hasTreasure() && pirate.getReloadTurns() <= 0)) { //Go dangerous if got no treasure but have booze
- Collections.reverse(unsorted); //Dangerous road
- game.debug("We went the dangerous road! ID: " + pirate.getId());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement