jeudi 8 septembre 2016

java.lang.IllegalArgumentException with Random

I am trying to generate a random number and I am getting this:

2
Exception in thread "Thread-0" java.lang.IllegalArgumentException: bound must be positive
    at java.util.Random.nextInt(Unknown Source)
    at me.xthegamerplayz.FirstGame.board.Black_AI.move(Black_AI.java:77)
    at me.xthegamerplayz.FirstGame.board.ChessBoard.tick(ChessBoard.java:33)
    at me.xthegamerplayz.FirstGame.board.ChessBoard.<init>(ChessBoard.java:21)
    at me.xthegamerplayz.FirstGame.Game.render(Game.java:124)
    at me.xthegamerplayz.FirstGame.Game.run(Game.java:70)
    at java.lang.Thread.run(Unknown Source)

Strange thing is that the bound is positive as the bound is the number above the stacktrace.

Here is what I am using to generate the random number in case it helps

Random rnd = new Random();

System.out.println(defensePossibilities.get(p).size());
int piece2 = rnd.nextInt(defensePossibilities.get(p).size());




Aucun commentaire:

Enregistrer un commentaire