Package edu.uky.ai.tic.ai

# Class GameTree

java.lang.Object
edu.uky.ai.tic.ai.GameTree

    public class GameTree
    extends java.lang.Object

A game tree is a representation of all the possible states that could occur during the play of game and how one state is reached from another.

Author:
  Stephen G. Ware

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `java.util.ArrayList<GameTree>` | `children` | This node's children nodes (i.e.
  `Move` | `move` | The move to resulted in the current state
  `GameTree` | `parent` | The parent node of this tree (i.e.
  `State` | `state` | The current state of the game
  `double` | `value` | The utility value of this state (i.e.

- ## Constructor Summary

  Constructors
  Modifier | Constructor | Description
  --- | --- | ---
  `protected` | `GameTree​(Move move, State state, GameTree parent)` | Constructs a new game tree with a current state that resulted from taking a given move.
  `` | `GameTree​(State initial)` | Constructs a new game tree with some initial state as the root.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `GameTree` | `getNextChild()` | Constructs and returns the next child node of this node.
  `boolean` | `hasNextChild()` | Returns true if this node has more children nodes which have not yet been expanded.
  `int` | `size()` | Returns the number of nodes in this tree.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### move

    public final Move move
    The move to resulted in the current state

  - ### state

    public final State state
    The current state of the game

  - ### parent

    public final GameTree parent
    The parent node of this tree (i.e. the state before this state)

  - ### children

    public final java.util.ArrayList<GameTree> children
    This node's children nodes (i.e. all possible next states)

  - ### value

    public double value
    The utility value of this state (i.e. how desirable it is for the player)

- ## Constructor Details

  - ### GameTree

    public GameTree​(State initial)
    Constructs a new game tree with some initial state as the root.
    Parameters:
      `initial` - the initial state of the game

  - ### GameTree

    protected GameTree​(Move move, State state, GameTree parent)
    Constructs a new game tree with a current state that resulted from taking a given move.
    Parameters:
      `move` - the move that resulted in this state
      `state` - the state of the game after making that move
      `parent` - the parent node (i.e. the previous state)

- ## Method Details

  - ### size

    public int size()
    Returns the number of nodes in this tree.
    Returns:
      the number of nodes

  - ### hasNextChild

    public boolean hasNextChild()
    Returns true if this node has more children nodes which have not yet been expanded.
    Returns:
      true if there are more children nodes to add, false otherwise

  - ### getNextChild

    public GameTree getNextChild()
    Constructs and returns the next child node of this node.
    Returns:
      the next child node