games.strategy.common.player.ai
Class AIAlgorithm
java.lang.Object
games.strategy.common.player.ai.AIAlgorithm
public class AIAlgorithm
- extends java.lang.Object
Utility class implementing AI game algorithms.
Currently, minimax and alpha-beta algorithms are implemented.
- Version:
- $LastChangedDate: 2008-01-04 14:33:48 -0800 (Fri, 04 Jan 2008) $
- Author:
- Lane Schwartz
- See Also:
- "Chapter 6 of Artificial Intelligence, 2nd ed. by Stuart Russell & Peter Norvig"
|
Method Summary |
static
|
alphaBetaSearch(GameState<Play> state)
Find the optimal next play to perform from the given game state,
using the alpha-beta algorithm. |
static
<Play> java.util.Stack<Play> |
|
depthFirstSearch(GameState<Play> state,
int maxDepth)
|
static
|
minimaxSearch(GameState<Play> state)
Find the optimal next play to perform from the given game state,
using the minimax algorithm. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AIAlgorithm
public AIAlgorithm()
depthFirstSearch
public static <Play> java.util.Stack<Play> depthFirstSearch(GameState<Play> state,
int maxDepth)
alphaBetaSearch
public static <Play> Play alphaBetaSearch(GameState<Play> state)
- Find the optimal next play to perform from the given game state,
using the alpha-beta algorithm.
- Type Parameters:
Play - class capable of representing a game play- Parameters:
state - current game state
- Returns:
- the optimal next play
minimaxSearch
public static <Play> Play minimaxSearch(GameState<Play> state)
- Find the optimal next play to perform from the given game state,
using the minimax algorithm.
- Type Parameters:
Play - class capable of representing a game play- Parameters:
state - current game state
- Returns:
- the optimal next play