public class RemoteReversiPlayer extends java.rmi.server.UnicastRemoteObject implements ReversiPlayerInterface
JavaProcess
and run remotely using Remote Method Invocation - neat.
Author: Ondrej Vanek
Date: 10/4/12
Time: 11:09 AMModifier and Type | Field and Description |
---|---|
private java.lang.String |
naming |
private ReversiPlayerInterface |
player |
Modifier | Constructor and Description |
---|---|
protected |
RemoteReversiPlayer(ReversiPlayerInterface player) |
Modifier and Type | Method and Description |
---|---|
void |
endGame()
Signalizes end of the game.
|
int |
getEmptySquareColor()
Gets the color of the empty square.
|
int |
getMyColor()
Gets the color of the player.
|
java.lang.String |
getName()
Returns name of the reversi player.
|
int |
getOpponentColor()
Gets the color of the opponent player.
|
void |
init(int boardWidth,
int boardHeight,
int myColor,
int opponentColor)
Initializes the player with game parameters.
|
private void |
initRMI(RemoteReversiPlayer rmiPlayer,
java.lang.String naming,
int port)
TODO - clean prints when tested properly.
|
static void |
main(java.lang.String[] args) |
ReversiMove |
makeNextMove(int[][] board)
makeNextTurn is called by the reversi server when the player has to compute the next move.
|
clone, exportObject, exportObject, exportObject, unexportObject
private ReversiPlayerInterface player
private java.lang.String naming
protected RemoteReversiPlayer(ReversiPlayerInterface player) throws java.rmi.RemoteException
java.rmi.RemoteException
public void init(int boardWidth, int boardHeight, int myColor, int opponentColor) throws java.rmi.RemoteException
ReversiPlayerInterface
init
in interface ReversiPlayerInterface
boardWidth
- WIDTH of the boardboardHeight
- HEIGHT of the boardmyColor
- color of the playeropponentColor
- color of the opponentjava.rmi.RemoteException
public int getMyColor() throws java.rmi.RemoteException
ReversiPlayerInterface
getMyColor
in interface ReversiPlayerInterface
java.rmi.RemoteException
public int getOpponentColor() throws java.rmi.RemoteException
ReversiPlayerInterface
getOpponentColor
in interface ReversiPlayerInterface
java.rmi.RemoteException
public int getEmptySquareColor() throws java.rmi.RemoteException
ReversiPlayerInterface
getEmptySquareColor
in interface ReversiPlayerInterface
java.rmi.RemoteException
public java.lang.String getName() throws java.rmi.RemoteException
ReversiPlayerInterface
getName
in interface ReversiPlayerInterface
java.rmi.RemoteException
public ReversiMove makeNextMove(int[][] board) throws java.rmi.RemoteException
ReversiPlayerInterface
ReversiMove
class encapsulating the coordinates of the stone to be put on the board.makeNextMove
in interface ReversiPlayerInterface
board
- - contains actual map of the board represented by two-dimensional matrix.
Each sqaure contains number of -1 representing empty square and number 0 and 1 representing players' stones.java.rmi.RemoteException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
private void initRMI(RemoteReversiPlayer rmiPlayer, java.lang.String naming, int port) throws java.lang.Exception
rmiPlayer
- naming
- port
- java.lang.Exception
public void endGame()
ReversiPlayerInterface
endGame
in interface ReversiPlayerInterface