Glomus.Server
Class AIplayer

java.lang.Object
  extended by Glomus.Server.Player
      extended by Glomus.Server.AIplayer

public class AIplayer
extends Player

The Player Class is used within the Server to keep track of AI players. The Player class has cards, a location, and a character that it is playing as. The Game class uses the Player to determine if an illegal move has been made, and to communicate with the actual AI Player


Constructor Summary
AIplayer(java.net.Socket link)
          Creates the server-side representation of an AI player.
 
Method Summary
 java.lang.String accuse()
          Asks the Player to communicate with its AI counterpart and make an accusation if they wish
 void deletePlayer()
          Closes all I/O streams and sockets for this player.
 void forward(java.lang.String message)
          Forwards the broadcast message to its AI counterpart
 java.lang.String[] getAnswer()
          Asks the player to tell us all the pieces of the answer that it knows for sure
 java.lang.String refute(java.lang.String claim)
          Asks the Player to communicate with its AI counterpart and make a refutation of the last suggestion (if it can)
 java.lang.String suggest()
          Asks the Player to communicate with its AI counterpart and make a suggestion
 
Methods inherited from class Glomus.Server.Player
forceMove, getCards, getInit, getLocation, getName, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AIplayer

public AIplayer(java.net.Socket link)
         throws java.io.IOException
Creates the server-side representation of an AI player. Note, the constructor only initializes the data that is neccesary for communication, in order to play a new game, the newGame method must be called

Parameters:
The - Socket on which the real AI player is communicating
Throws:
java.io.IOException - If the I/O streams from the socket cannot be initialized
Method Detail

suggest

public java.lang.String suggest()
                         throws IllegalTurnException,
                                TimeoutException,
                                NetworkFailureException
Asks the Player to communicate with its AI counterpart and make a suggestion

Overrides:
suggest in class Player
Returns:
The claim made by the player, in the form, "claim [suspect] [weapon] [room] [player]"
Throws:
IllegalTurnException - When the number of arguments recieved from the distant AI player was either too few or too many, and when the suggestion's location is not a room that can be moved to from the player's prior location
TimeoutException - If the AI player takes too long to decide what it wants to do
NetworkFailureException - If the AIplayer loses contact with the distant AI

refute

public java.lang.String refute(java.lang.String claim)
                        throws IllegalTurnException,
                               TimeoutException,
                               NetworkFailureException
Asks the Player to communicate with its AI counterpart and make a refutation of the last suggestion (if it can)

Overrides:
refute in class Player
Parameters:
The - claim to refute, in the form "[suspect] [weapon] [room] [player]"
Returns:
the ability or inability of the AI player to refute the last suggestion; in the format "show" if not possible, and "show [value]" if possible
Throws:
IllegalTurnException - When the number of arguments recieved from the distant AI player was either too few or too many, and when the AI either didn't refute when it could have, or if it refuted with a card it does not have
TimeoutException - If the AI player takes too long to decide what it wants to do
NetworkFailureException - If the AIplayer loses contact with the distant AI

accuse

public java.lang.String accuse()
                        throws IllegalTurnException,
                               TimeoutException,
                               NetworkFailureException
Asks the Player to communicate with its AI counterpart and make an accusation if they wish

Overrides:
accuse in class Player
Returns:
the message to broadcast to all the other players about this player's accusation; in the format "accuse" if not desired and "accuse [suspect] [weapon] [room]" if desired
Throws:
IllegalTurnException - When the number of arguments recieved from the distant AI player was either too few or too many
TimeoutException - If the AI player takes too long to decide what it wants to do
NetworkFailureException - If the AIplayer loses contact with the distant AI

getAnswer

public java.lang.String[] getAnswer()
                             throws IllegalTurnException,
                                    TimeoutException,
                                    NetworkFailureException
Asks the player to tell us all the pieces of the answer that it knows for sure

Returns:
The suspect, weapon, and room known to be the answer (in that order)
Throws:
IllegalTurnException - When the number of arguments recieved from the distant AI player was either too few or too many
TimeoutException - If the AI player takes too long to decide what it wants to do
NetworkFailureException - If the AIplayer loses contact with the distant AI

forward

public void forward(java.lang.String message)
Forwards the broadcast message to its AI counterpart

Overrides:
forward in class Player
Parameters:
The - message to forward to the AI player

deletePlayer

public void deletePlayer()
Closes all I/O streams and sockets for this player. This must be called for each player in a game, before the game signals that it is finished

Overrides:
deletePlayer in class Player