ArrayList freePoints = new ArrayList(); Random r = new Random(); // Walk through all the points and store those that are free for (Character key : board.getPoints().keySet()) { if (board.getPoint(key).getPointState() == PointState.FREE) { freePoints.add(key); } } // Roll a dice and pick a random point return freePoints.get(r.nextInt(freePoints.size()));