Class PlayerNode.Local<P extends Player>

java.lang.Object
org.xxdc.oss.example.PlayerNode.Local<P>
Type Parameters:
P - the type of the player implementation
All Implemented Interfaces:
Serializable, ToIntFunction<GameState>, PlayerNode
Enclosing interface:
PlayerNode

public static final class PlayerNode.Local<P extends Player> extends Object implements PlayerNode, Serializable
Represents a local player node that implements the player's logic directly in the application. The local player node is responsible for providing the player's next move to apply to the game board. The local player node is serializable, allowing it to be persisted and transferred between processes.
See Also:
  • Constructor Details

    • Local

      public Local(String playerMarker, P player)
      Constructs a new Local PlayerNode instance with the given player marker and player implementation.
      Parameters:
      playerMarker - the marker to identify this player
      player - the player implementation to use for this node
  • Method Details

    • applyAsInt

      public int applyAsInt(GameState state)
      Gets the player's next move to apply to the given game board.
      Specified by:
      applyAsInt in interface PlayerNode
      Specified by:
      applyAsInt in interface ToIntFunction<P extends Player>
      Parameters:
      state - the current state of the game
      Returns:
      the location on the game board where the move was made
    • playerMarker

      public String playerMarker()
      Description copied from interface: PlayerNode
      Gets the player's marker: a string representation of the player's identity. Returns the marker (e.g. "X" or "O") used by this player.
      Specified by:
      playerMarker in interface PlayerNode
      Returns:
      the player's marker
    • player

      public Player player()
    • toString

      public String toString()
      Overrides:
      toString in class Object