~ubuntu-branches/ubuntu/precise/triplea/precise

« back to all changes in this revision

Viewing changes to src/games/strategy/common/player/ai/GameState.java

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2011-11-11 21:40:11 UTC
  • Revision ID: package-import@ubuntu.com-20111111214011-sehf2rwat36o2xqf
Tags: upstream-1.3.2.2
ImportĀ upstreamĀ versionĀ 1.3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
13
 */
 
14
package games.strategy.common.player.ai;
 
15
 
 
16
import java.util.Collection;
 
17
 
 
18
/**
 
19
 * Abstract class representing game state, for use by AI game algorithms.
 
20
 *
 
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"
 
25
 */
 
26
public abstract class GameState<Play>
 
27
{
 
28
    /**
 
29
     * Get the state which will result from performing the specified play.
 
30
     * 
 
31
     * @param play a legal game play
 
32
     * @return the state which will result from performing the specified play
 
33
     */
 
34
    public abstract GameState<Play> getSuccessor(Play play);
 
35
 
 
36
    /**
 
37
     * Get the play which resulted in this state.
 
38
     * @return the play which resulted in this state
 
39
     */
 
40
    public abstract Play getMove();
 
41
 
 
42
    /**
 
43
     * Get the collection of all states which can be reached from this state by performing a legal play.
 
44
     * 
 
45
     * @return <code>Collection</code> of successor states
 
46
     */
 
47
    public abstract Collection<GameState<Play>> successors();
 
48
 
 
49
    /** 
 
50
     * Get the utility (or heuristic evaluation score) for this state.
 
51
     * @return the utility (or heuristic evaluation score) for this state
 
52
     */
 
53
    public abstract float getUtility();
 
54
 
 
55
    /** 
 
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.
 
58
     */
 
59
    public abstract boolean gameIsOver();
 
60
    
 
61
    /** 
 
62
     * Test to see if the current state represents a pseudu-terminal state.
 
63
     * This method is used during alpha-beta pruning.
 
64
     * <p>
 
65
     * If this method returns <code>true</code>, 
 
66
     * then <code>successors()</code> must return a non-empty <code>Collection</code>.
 
67
     * <p>
 
68
     * Likewise, if this method returns <code>false</code>,
 
69
     * then <code>successors()</code> must return an empty <code>Collection</code>.
 
70
     * <p>
 
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.
 
74
     */
 
75
    public abstract boolean cutoffTest();
 
76
    
 
77
}