Fix Random.nextInt(int) in Random.java

This commit is contained in:
Quentin Legot 2021-03-27 15:05:01 +01:00
parent de37c534c0
commit 1ffc7ded74

View File

@ -2,12 +2,12 @@ package battleship.model.player;
import battleship.utils.Pair; import battleship.utils.Pair;
public class Random extends Player{ public class Random extends Player {
@Override @Override
public Pair<Integer,Integer> chooseMove() { public Pair<Integer,Integer> chooseMove() {
Random rand = new Random(); java.util.Random rand = new java.util.Random();
int index = validMoves().get(rand.nextInt(validMoves().size())); // Pair<Integer, Integer> index = validMoves().get(rand.nextInt(validMoves().size()));
return validMoves().get(index); return validMoves().get(rand.nextInt(validMoves().size()));
} }
} }