fix package, fix get random node
This commit is contained in:
		
							parent
							
								
									f60debdcd3
								
							
						
					
					
						commit
						aa8afa5b6e
					
				| @ -87,7 +87,7 @@ public class State { | ||||
|     void randomPlay() { | ||||
|         List<Position> 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)); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import com.baeldung.algorithms.hillclimbing.HillClimbing; | ||||
| import com.baeldung.algorithms.hillclimbing.State; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import com.baeldung.algorithms.middleelementlookup.MiddleElementLookup; | ||||
| import com.baeldung.algorithms.middleelementlookup.Node; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import com.baeldung.algorithms.automata.*; | ||||
| import org.junit.Test; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms; | ||||
| package com.baeldung.algorithms; | ||||
| 
 | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms.binarysearch; | ||||
| package com.baeldung.algorithms.binarysearch; | ||||
| 
 | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms.mcts; | ||||
| package com.baeldung.algorithms.mcts; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| @ -1,4 +1,4 @@ | ||||
| package algorithms.minimax; | ||||
| package com.baeldung.algorithms.minimax; | ||||
| 
 | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user