public void updateScores(Array<Player> players, Array<ServerShip> ships, float scoreMultiplier) { for (Player p : players) { scores.put(p.getId(), 0f); } // give out points according to what ships are nearby the gathering point // first store weights of every ship float totalWeight = 0f; for (ServerShip ship : ships) { float dst = ship.getBody().getWorldCenter().dst(position); dst = Math.max(3, dst); float weight = 10f / (float) Math.pow(dst, 0.6f); // todo multiply with the cost of the ship totalWeight += weight; long ownerId = ship.getPlayer().getId(); Float currentWeight = scores.get(ownerId); scores.put(ownerId, currentWeight + weight); } if (totalWeight == 0f) { return; } for (Player p : players) { float score = scores.get(p.getId()) / totalWeight * SCORE_PER_TICK * scoreMultiplier; p.setScore(p.getScore() + score); } }