|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbot.talk.Talk
bot.talk.Talk_ACPC
public class Talk_ACPC
This class talks to the poker server. All message protocol dependent stuff should be in here.
Field Summary | |
---|---|
private java.lang.String |
ClassOfPlayer
|
private boolean |
gameOver
Is the round over? |
private java.io.InputStream |
is
Stream from the server. |
private java.lang.String |
lastGameStateString
This is the current game state. |
private boolean |
matchOver
Has an ENDGAME signal been received? |
static java.lang.String |
messageTerminator
Terminates the messages. |
private java.io.OutputStream |
os
Stream to the server. |
private boolean |
protocolNoLimit
|
private java.net.Socket |
socket
Socket connecting to the server. |
private boolean |
tournament
In a tournament the bot will be started via script and therefore announce itself as "AAAIPLAYER". |
Fields inherited from class bot.talk.Talk |
---|
bot, port, serverAdress |
Constructor Summary | |
---|---|
Talk_ACPC(Bot bot,
java.lang.String serverAdress,
int port)
Calls super constructor with the given parameters. |
Method Summary | |
---|---|
private void |
close()
Closes the connection. |
private void |
connect(java.net.InetAddress iaddr,
int port)
Tries to set up a socket and to get the input and output stream. |
private Card[] |
extractCards(java.lang.String cardString)
Extracts the Cards from the given string and returns it. |
private java.lang.String |
extractLastAction(java.lang.String roundHistory)
Extracts the string representing the last action out of the given string. |
private void |
gameLoop()
|
boolean |
initConnection()
Tries to connect to the given server (and enters a room). |
private void |
initHand(int position,
int hand,
Card[] holeCards,
Card[] boardCards)
Initialize the hand. |
private boolean |
isComplete(java.lang.String message)
Tests if the message is complete (contains a terminal character) |
private void |
processMessage(java.lang.String message)
Processes the given message. |
private java.lang.String |
receiveMessage()
Receive a message from the server. |
void |
run()
Triggers the the game loop. |
private boolean |
sendAction(char action)
Send an action (action should be 'r', 'c', or 'f'). |
private boolean |
sendAction(java.lang.String action)
Send an action string (action should be r?? |
boolean |
sendCall()
Sends a call action. |
boolean |
sendFold()
Sends a fold action. |
private boolean |
sendMessage(java.lang.String message)
Sends the given message to the server. |
boolean |
sendRaise()
Sends a raise action. |
boolean |
sendRaise(int finalInPot)
Sends a raise action. |
private void |
setBoardCards(int round,
java.lang.String cardString)
Extracts the cards from the given string and makes the bot set the given cards to the given round. |
private void |
setEnemyHoleCards(java.lang.String message)
Extracts all hole cards from the given string and calls the method of the bot to set them. |
private void |
setPlayers(java.lang.String[] playerDesc)
Extracts the player information for each player (names and buy ins) and calls the according method of the bot. |
private void |
updateState(java.lang.String gameStorageString)
Updates the state of the bot depending of the given string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String messageTerminator
private final java.lang.String ClassOfPlayer
private final boolean tournament
private java.net.Socket socket
private java.io.InputStream is
private java.io.OutputStream os
private boolean matchOver
private boolean gameOver
private boolean protocolNoLimit
private java.lang.String lastGameStateString
Constructor Detail |
---|
public Talk_ACPC(Bot bot, java.lang.String serverAdress, int port)
bot
- serverAdress
- port
- Method Detail |
---|
public boolean initConnection()
initConnection
in class Talk
public void run()
Talk
run
in class Talk
public boolean sendFold()
Talk
sendFold
in class Talk
public boolean sendCall()
Talk
sendCall
in class Talk
public boolean sendRaise()
Talk
sendRaise
in class Talk
public boolean sendRaise(int finalInPot)
Talk
sendRaise
in class Talk
private void gameLoop() throws java.io.IOException
java.io.IOException
private void connect(java.net.InetAddress iaddr, int port) throws java.io.IOException
iaddr
- port
-
java.io.IOException
private boolean sendMessage(java.lang.String message)
private void close() throws java.io.IOException
java.io.IOException
private boolean isComplete(java.lang.String message)
private boolean sendAction(char action)
private boolean sendAction(java.lang.String action)
private java.lang.String receiveMessage()
private void processMessage(java.lang.String message)
message
- The message containing the data which are to set.private void setBoardCards(int round, java.lang.String cardString)
round
- Round in which the cards are revealedcardString
- Cards which are revealedprivate java.lang.String extractLastAction(java.lang.String roundHistory)
roundHistory
- String representing the actions of the round
private void updateState(java.lang.String gameStorageString)
gameStorageString
- String containing the changes to the stateprivate void initHand(int position, int hand, Card[] holeCards, Card[] boardCards)
position
- Own positionhand
- Hand countholeCards
- own hole cardsboardCards
- board cards which are revealed at the start of the hand // TODO are there any poker types with that?private Card[] extractCards(java.lang.String cardString)
cardString
- A string representing the card which are to be returned
private void setEnemyHoleCards(java.lang.String message)
message
- A string containing the information about the revealed hole cardsprivate void setPlayers(java.lang.String[] playerDesc)
playerDesc
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |