Interface PlayerNode

All Superinterfaces:
ToIntFunction<GameState>
All Known Implementing Classes:
PlayerNode.Local, PlayerNode.Remote

public sealed interface PlayerNode extends ToIntFunction<GameState> permits PlayerNode.Local<P>, PlayerNode.Remote
The `PlayerNode` interface represents a player in a game. It provides methods to get the player's marker and apply the player's next move to the game state.

The `Local` implementation of `PlayerNode` represents a local player, where the player's logic is implemented directly in the application.

The `Remote` implementation of `PlayerNode` represents a remote player, where the player's logic is implemented in a separate process and communicated with the application through a transport mechanism.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Represents a local player node that implements the player's logic directly in the application.
    static final class 
    Represents a remote player node that communicates with a client over a transport server.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the player's next move to apply to the game board with the current game state.
    Gets the player's marker: a string representation of the player's identity.
  • Method Details

    • playerMarker

      String playerMarker()
      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.
      Returns:
      the player's marker
    • applyAsInt

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