Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## glassfrog.players
Class AAAIPlayer

    java.lang.Object
      glassfrog.players.Player
          glassfrog.players.AAAIPlayer

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable<Player>, java.lang.Runnable

    public class AAAIPlayer

extends Player
implements java.lang.Runnable

A player used to connect the AAAI bots to the server. This class acts as an interface for the bots to connect into the code. They are invoked by a BotManager and thier parameters are specified in a config file that the server parses. This is to get around setting things like the name, seat and buyin from the bot's perspective, but rather the config file handles all of that information and simple adds the AAAIPlayer to the room and the AAAIPlayer opens a port to the bot through which the Room is able to send and recieve messages

Author:
  jdavidso
See Also:
  Serialized Form

Field Summary
`private java.io.BufferedReader` | `br`
`private java.lang.String` | `location`
`private java.lang.String` | `logPrefix`
`private int` | `port`
`private java.io.PrintWriter` | `pw`
`private java.io.File` | `script`
`private java.net.Socket` | `socket`
`private java.net.ServerSocket` | `ss`

Constructor Summary
`AAAIPlayer(java.lang.String name, int buyIn, java.lang.String location, java.lang.String scriptPath, int portBase, java.lang.String logPrefix)` Invoke the super constructor, set up the server socket, get the port, and then run the script associated with the bot

Method Summary
`java.lang.String` | `getAction()` Gets the action of the player through the BufferedReader
`java.lang.String` | `getLocation()` Return the machine location of the player
`int` | `getPort()` Get the port the player is associated with
`java.lang.String` | `getScriptPath()` Get the path the bot is running on
`java.net.Socket` | `getSocket()` Get the @Socket the player is connected on
`void` | `initTimeout(int timeout)` Used to set the player timeout to 60s per hand
`boolean` | `isAAAIPlayer()` Overrides the @Player call to this method and returns True
`void` | `reconnect(java.net.Socket s, java.lang.String location, java.lang.String scriptPath)` Used to reconnect a player upon dealer reloads.
`void` | `run()` Runs the script associated with this player.
`void` | `shutdown()` Override's the @Player implementation of this method and closes the @Socket the @PrintWriter and the @BufferedReader down
`java.lang.String` | `toString()` Returns AAAI appended to the @Player representation of the object
`void` | `update(java.lang.String gamestate)` Send the gamestate to the player through the PrintWriter

Methods inherited from class glassfrog.players.Player
`addToScore, bet, call, compareTo, fold, getBuyIn, getCardString, getCurrentBet, getHandRank, getHandString, getName, getPosition, getScore, getSeat, getStack, getTotalCommitedToPot, isActed, isAllIn, isFolded, isGuiPlayer, isSocketPlayer, payout, postBlind, resetHand, resetPlayer, resetRound, resetStack, setBuyIn, setCardString, setHandRank, setHandString, setName, setPosition, setScore, setSeat, setStack, subtractTotalCommitedToPot, toShortString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### ss

    private transient java.net.ServerSocket ss

### socket

    private transient java.net.Socket socket

### pw

    private transient java.io.PrintWriter pw

### br

    private transient java.io.BufferedReader br

### port

    private transient int port

### location

    private transient java.lang.String location

### logPrefix

    private transient java.lang.String logPrefix

### script

    private transient java.io.File script

Constructor Detail

### AAAIPlayer

    public AAAIPlayer(java.lang.String name,
                      int buyIn,
                      java.lang.String location,
                      java.lang.String scriptPath,
                      int portBase,
                      java.lang.String logPrefix)
               throws java.io.IOException

  Invoke the super constructor, set up the server socket, get the port, and then run the script associated with the bot

  Parameters:
    `name` - The players name
    `buyIn` - The buyIn amount to play the game
    `location` -
    `portBase` - The portBase used by the server
    `scriptPath` - A path to the shell script
    `logPrefix` - A string telling the bot what to append to the out and error logs
  Throws:
    `java.io.IOException`

Method Detail

### getAction

    public java.lang.String getAction()

  Gets the action of the player through the BufferedReader

  Specified by:
    `getAction` in class `Player`
  Returns:
    the action sent or "f" on error

### update

    public void update(java.lang.String gamestate)

  Send the gamestate to the player through the PrintWriter

  Specified by:
    `update` in class `Player`
  Parameters:
    `gamestate` - The gamestate to send

### getPort

    public int getPort()

  Get the port the player is associated with

  Returns:
    the port

### getLocation

    public java.lang.String getLocation()

  Return the machine location of the player

  Returns:
    a String representing the machine location of the bot

### getScriptPath

    public java.lang.String getScriptPath()

  Get the path the bot is running on

  Returns:
    A String representing the executeable path of the bot

### run

    public void run()

  Runs the script associated with this player. It will wait 5s to allow time for the ServerSocket to start accepting connections

  Specified by:
    `run` in interface `java.lang.Runnable`

### isAAAIPlayer

    public boolean isAAAIPlayer()

  Overrides the @Player call to this method and returns True

  Overrides:
    `isAAAIPlayer` in class `Player`
  Returns:
    True

### reconnect

    public void reconnect(java.net.Socket s,
                          java.lang.String location,
                          java.lang.String scriptPath)
                   throws java.io.IOException

  Used to reconnect a player upon dealer reloads. This takes a socket connection and re-initializes the @PrintWriter and @BufferedReader

  Parameters:
    `s` - a socket to reconnect to
    `location` - a location to reconnect to
    `scriptPath` - a path where the bot executeable is located
  Throws:
    `java.io.IOException`

### getSocket

    public java.net.Socket getSocket()

  Get the @Socket the player is connected on

  Returns:
    the @Socket the player is connected on

### shutdown

    public void shutdown()

  Override's the @Player implementation of this method and closes the @Socket the @PrintWriter and the @BufferedReader down

  Specified by:
    `shutdown` in class `Player`

### toString

    public java.lang.String toString()

  Returns AAAI appended to the @Player representation of the object

  Overrides:
    `toString` in class `Player`
  Returns:
    AAAI appended to the front of the @Player toString method

### initTimeout

    public void initTimeout(int timeout)

  Used to set the player timeout to 60s per hand

  Overrides:
    `initTimeout` in class `Player`
  Parameters:
    `timeout` - A timeout for the bot

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD