001    package core;
002    
003    import net.antichess.ai.AiPlayer;
004    
005    /**
006     * Represents an abstract player that can make moves.
007     * 
008     * @specfield color : Color // the color of the player
009     */
010    abstract public class Player implements AiPlayer
011    {
012            final private Color color;
013    
014            /**
015             * Creates a new player of that color
016             * 
017             * @param color
018             *            of the player
019             */
020            public Player(Color color)
021            {
022                    this.color = color;
023            }
024    
025            /**
026             * Gets the next move of the player, given the opponents move.
027             * 
028             * @param opponentsMove
029             *            the opponents move
030             * @modifies state
031             * @requires opponentsMove not null
032             */
033            abstract public Move askForMove(Move opponentsMove);
034    
035            public Move askForMove(Move opponentsMove, long timeRemainingInMillis,
036                                   long opponentTimeRemainingInMillis) {
037                return askForMove(opponentsMove);
038            }
039    
040            /**
041             * @see Piece
042             */
043            public String getMove(String lastMove, long timeRemainingInMillis,
044                            long opponentTimeRemainingInMillis)
045            {
046                    Move lastM = Move.fromString(lastMove);
047                    Move thisM = askForMove(lastM, timeRemainingInMillis,
048                                            opponentTimeRemainingInMillis);
049                    return thisM.toString();
050            }
051    
052            /**
053             * Filler for now
054             */
055            public byte[] getPersistentState()
056            {
057                    return new byte[0];
058            }
059    
060            /**
061             * @returns the color of the player
062             */
063            public Color getColor()
064            {
065                    return color;
066            }
067    
068            /**
069             * Has the player make a series of moves. Used to get the AI player up to
070             * speed on a newly loaded game
071             */
072        abstract public void update(Game game);
073                
074    }