referee
Class HumanPlayer

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by referee.HumanPlayer
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, Player

public class HumanPlayer
extends java.rmi.server.UnicastRemoteObject
implements Player

Title: Player

Description: Testing representation of a checkers player

Copyright: Copyright (c) 2004

Company:

Version:
1.0
Author:
Matthew Evett
See Also:
Serialized Form

Field Summary
static int BLACK_KING
           
static int BLACK_PAWN
           
static int NO_PIECE
           
static int WHITE_KING
           
static int WHITE_PAWN
           
 
Constructor Summary
HumanPlayer(java.lang.String name)
           
 
Method Summary
 int[] getMove(int[] board, boolean isWhite, int movesRemaining)
          This method returns a move for the given board, board.
 java.lang.String getName()
          Here's your chance to be imaginative.
static void main(java.lang.String[] args)
          Debugging: creates two players named Black and White and registers them with RMI.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_PIECE

public static final int NO_PIECE
See Also:
Constant Field Values

WHITE_PAWN

public static final int WHITE_PAWN
See Also:
Constant Field Values

WHITE_KING

public static final int WHITE_KING
See Also:
Constant Field Values

BLACK_PAWN

public static final int BLACK_PAWN
See Also:
Constant Field Values

BLACK_KING

public static final int BLACK_KING
See Also:
Constant Field Values
Constructor Detail

HumanPlayer

public HumanPlayer(java.lang.String name)
            throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
Method Detail

getMove

public int[] getMove(int[] board,
                     boolean isWhite,
                     int movesRemaining)
              throws java.rmi.RemoteException
This method returns a move for the given board, board.

Specified by:
getMove in interface Player
Parameters:
board - --- The board is encoded as a 33 integer array. board[0] is unused. For i from 1 to 32, board[i] indicates what piece, if any is position i on the board, using the official checkers numbering scheme. board[i] = -2 for a black king, -1 for a black pawn, 1 for a white pawn, 2 for a white king, and is 0 if the position is unoccupied
isWhite - is true if the player should make a move for White.
movesRemaining - is the number of moves remaining before a draw is called
Returns:
First element of the array is the position of the piece to be moved. The remaining elements are subsequent positions to which that piece moves. (There will usually be only one remaining element, unless result encodes a multiple capture/jumping move.) Thus a move from position 17 to 10, jumping over an opposition piece at position 14 would be encoded via the array: {17, 10}. It is important that the length of the array be exactly 1+ the number of moves made by the piece.
Throws:
java.rmi.RemoteException

main

public static void main(java.lang.String[] args)
Debugging: creates two players named Black and White and registers them with RMI.

Parameters:
args - Two command-line arguments: the first should be either '1' or '2', indicating whether the created Player should be rmi-registered as 'first' or 'second'. The second argument should be the name of the Player.

Example usage:
java -Djava.security.policy=permit.txt referee.HumanPlayer 1 "Fraser"


getName

public java.lang.String getName()
                         throws java.rmi.RemoteException
Here's your chance to be imaginative.

Specified by:
getName in interface Player
Returns:
the name of the agent (hopefully something memorable!)
Throws:
java.rmi.RemoteException