[JAVA-8698] Fix bug in algorithm
This commit is contained in:
parent
17981c9036
commit
25b65ddb33
|
@ -18,15 +18,16 @@ public class Travel {
|
|||
}
|
||||
|
||||
public void generateInitialTravel() {
|
||||
if (travel.isEmpty())
|
||||
if (travel.isEmpty()) {
|
||||
new Travel(10);
|
||||
}
|
||||
Collections.shuffle(travel);
|
||||
}
|
||||
|
||||
public void swapCities() {
|
||||
int a = generateRandomIndex();
|
||||
int b = generateRandomIndex();
|
||||
previousTravel = travel;
|
||||
previousTravel = new ArrayList<>(travel);
|
||||
City x = travel.get(a);
|
||||
City y = travel.get(b);
|
||||
travel.set(a, y);
|
||||
|
|
Loading…
Reference in New Issue