2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
* You should have received a copy of the GNU General Public License
11
* along with this program; if not, write to the Free Software
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
package games.strategy.common.player.ai;
16
import java.util.Collection;
19
* Abstract class representing game state, for use by AI game algorithms.
21
* @param <Play> class capable of representing a game play
22
* @author Lane Schwartz
23
* @version $LastChangedDate: 2007-12-14 22:58:18 +0800 (Fri, 14 Dec 2007) $
24
* @see "Chapter 6 of Artificial Intelligence, 2nd ed. by Stuart Russell & Peter Norvig"
26
public abstract class GameState<Play>
29
* Get the state which will result from performing the specified play.
31
* @param play a legal game play
32
* @return the state which will result from performing the specified play
34
public abstract GameState<Play> getSuccessor(Play play);
37
* Get the play which resulted in this state.
38
* @return the play which resulted in this state
40
public abstract Play getMove();
43
* Get the collection of all states which can be reached from this state by performing a legal play.
45
* @return <code>Collection</code> of successor states
47
public abstract Collection<GameState<Play>> successors();
50
* Get the utility (or heuristic evaluation score) for this state.
51
* @return the utility (or heuristic evaluation score) for this state
53
public abstract float getUtility();
56
* Test to see if the current state represents an endgame state.
57
* @return <code>true</code> this state represents an endgame state, <code>false</code> otherwise.
59
public abstract boolean gameIsOver();
62
* Test to see if the current state represents a pseudu-terminal state.
63
* This method is used during alpha-beta pruning.
65
* If this method returns <code>true</code>,
66
* then <code>successors()</code> must return a non-empty <code>Collection</code>.
68
* Likewise, if this method returns <code>false</code>,
69
* then <code>successors()</code> must return an empty <code>Collection</code>.
71
* All endgame states are pseudo-terminal states.
72
* Additionally, any state which the AI search algorithm should not search beyond are pseudo-terminal states.
73
* @return <code>true</code> this state represents a pseudo-terminal state, <code>false</code> otherwise.
75
public abstract boolean cutoffTest();