diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java b/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java index d855f775a8..5d4b265500 100644 --- a/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java @@ -87,7 +87,7 @@ public class State { void randomPlay() { List availablePositions = this.board.getEmptyPositions(); int totalPossibilities = availablePositions.size(); - int selectRandom = (int) (Math.random() * ((totalPossibilities - 1) + 1)); + int selectRandom = (int) (Math.random() * totalPossibilities); this.board.performMove(this.playerNo, availablePositions.get(selectRandom)); } diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java b/algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java index 20f9e992b5..0ad6510e50 100644 --- a/algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java @@ -65,7 +65,7 @@ public class Node { public Node getRandomChildNode() { int noOfPossibleMoves = this.childArray.size(); - int selectRandom = (int) (Math.random() * ((noOfPossibleMoves - 1) + 1)); + int selectRandom = (int) (Math.random() * noOfPossibleMoves); return this.childArray.get(selectRandom); } diff --git a/algorithms/src/test/java/algorithms/AntColonyOptimizationLongRunningUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java similarity index 94% rename from algorithms/src/test/java/algorithms/AntColonyOptimizationLongRunningUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java index b0218ae23e..2ac7adc3aa 100644 --- a/algorithms/src/test/java/algorithms/AntColonyOptimizationLongRunningUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import org.junit.Assert; import org.junit.Test; diff --git a/algorithms/src/test/java/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java similarity index 92% rename from algorithms/src/test/java/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java index fa8ecdee77..e819da4b36 100644 --- a/algorithms/src/test/java/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import org.junit.Assert; import org.junit.Test; diff --git a/algorithms/src/test/java/algorithms/DijkstraAlgorithmLongRunningUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java similarity index 98% rename from algorithms/src/test/java/algorithms/DijkstraAlgorithmLongRunningUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java index 68386278fc..bbc4d4f398 100644 --- a/algorithms/src/test/java/algorithms/DijkstraAlgorithmLongRunningUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import org.junit.Test; diff --git a/algorithms/src/test/java/algorithms/HillClimbingAlgorithmUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java similarity index 98% rename from algorithms/src/test/java/algorithms/HillClimbingAlgorithmUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java index e4746b521c..e817d195b3 100644 --- a/algorithms/src/test/java/algorithms/HillClimbingAlgorithmUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import com.baeldung.algorithms.hillclimbing.HillClimbing; import com.baeldung.algorithms.hillclimbing.State; diff --git a/algorithms/src/test/java/algorithms/MiddleElementLookupUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java similarity index 99% rename from algorithms/src/test/java/algorithms/MiddleElementLookupUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java index 01f9ca2f76..2cda0ccb36 100644 --- a/algorithms/src/test/java/algorithms/MiddleElementLookupUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import com.baeldung.algorithms.middleelementlookup.MiddleElementLookup; import com.baeldung.algorithms.middleelementlookup.Node; diff --git a/algorithms/src/test/java/algorithms/RtFiniteStateMachineLongRunningUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java similarity index 98% rename from algorithms/src/test/java/algorithms/RtFiniteStateMachineLongRunningUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java index 99e962773f..fddccfcd9f 100644 --- a/algorithms/src/test/java/algorithms/RtFiniteStateMachineLongRunningUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import com.baeldung.algorithms.automata.*; import org.junit.Test; diff --git a/algorithms/src/test/java/algorithms/SimulatedAnnealingLongRunningUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java similarity index 90% rename from algorithms/src/test/java/algorithms/SimulatedAnnealingLongRunningUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java index 6ee129ece9..2ce7d75e43 100644 --- a/algorithms/src/test/java/algorithms/SimulatedAnnealingLongRunningUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import org.junit.Assert; import org.junit.Test; diff --git a/algorithms/src/test/java/algorithms/StringSearchAlgorithmsUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java similarity index 94% rename from algorithms/src/test/java/algorithms/StringSearchAlgorithmsUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java index c98a8a53f3..dfe015aad2 100755 --- a/algorithms/src/test/java/algorithms/StringSearchAlgorithmsUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java @@ -1,4 +1,4 @@ -package algorithms; +package com.baeldung.algorithms; import org.junit.Assert; diff --git a/algorithms/src/test/java/algorithms/binarysearch/BinarySearchUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java similarity index 95% rename from algorithms/src/test/java/algorithms/binarysearch/BinarySearchUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java index 74db4236b9..826682d373 100644 --- a/algorithms/src/test/java/algorithms/binarysearch/BinarySearchUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java @@ -1,4 +1,4 @@ -package algorithms.binarysearch; +package com.baeldung.algorithms.binarysearch; import java.util.Arrays; import java.util.List; diff --git a/algorithms/src/test/java/algorithms/mcts/MCTSUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java similarity index 98% rename from algorithms/src/test/java/algorithms/mcts/MCTSUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java index edbf21390d..59afed65de 100644 --- a/algorithms/src/test/java/algorithms/mcts/MCTSUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java @@ -1,4 +1,4 @@ -package algorithms.mcts; +package com.baeldung.algorithms.mcts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/algorithms/src/test/java/algorithms/minimax/MinimaxUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java similarity index 95% rename from algorithms/src/test/java/algorithms/minimax/MinimaxUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java index c07975bca0..59f0fcf053 100644 --- a/algorithms/src/test/java/algorithms/minimax/MinimaxUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java @@ -1,4 +1,4 @@ -package algorithms.minimax; +package com.baeldung.algorithms.minimax; import org.junit.Before; import org.junit.Test;