📄 abstractplayer.java
字号:
package com.ibm.crl.contest;
import java.awt.Point;
abstract public class AbstractPlayer {
/**
* NOT_AVAILABLE indicate that it's impossible to put any chess on the
* specified position on the chessboard.
*/
public static final byte NOT_AVAILABLE = 3;
/**
* AVAILABLE indicate that the specified position on the chessboard is empty
* at this time, and is possible to accept white or black chess in the
* future.
*/
public static final byte AVAILABLE = 0;
/**
* BLACK indicate that the specified position on the chessboard is a black
* chess.
*/
public static final byte BLACK = 1;
/**
* WHITE indicate that the specified position on the chessboard is a white
* chess.
*/
public static final byte WHITE = 2;
/**
* This function will be called at the beginning of the game. No matter
* which side you are.
* <p>
* Here is an example of how the totalMemoryLimit,
* totalMemoryInitLimit,totalMemoryOccupyLimit works together:
* <p>
* If totalMemoryAvailable=512000000, totalMemoryOccupyLimit=128000000, the
* client can load some data and at maximum take up to 128000000 bytes in
* the init() or myTurn() function. And whenever the the client function is
* called, it is guaranteed that the client can have 512000000 bytes of free
* memory to use before any garbage collection. If the client occupied too
* much memory which exceed the 128000000 limit, the client will lose the
* game (but can continue to play other games).<br>
* When the contest begin, maximum possible values of
* totalMemoryLimit,totalMemoryOccupyLimit will be given according to the
* hardware environment. Don't need to worry about these values if you are
* using reasonable memory space.
*
* @param chessContext
* A reference object which might be useful during the game
* @param chessboard
* A byte array which contains the current chessboard,
* chessboard[x][y] means row y, column x;
* @param totalTimeLimit
* The maximum time (in milliseconds) which the client can use
* during each game, zero if no limit. The timer will be started
* while calling the init() function and myTurn() function, and
* will be paused when the function returns.
* @param totalMemoryOccupyLimit
* The maximum memory (in bytes) which the client can occupy
* during each game, zero if no limit. Occupy means the client
* take some memory which can not be released after called the
* client functions.
* @param color
* true for black side, false for white side
* @return Undefined
*/
abstract public int init(ChessContext chessContext, byte[][] chessboard,
int totalTimeLimit, int totalMemoryOccupyLimit, boolean color);
// abstract public int init(ChessContext chessContext, byte[][] chessboard,
// int totalTimeLimit, int totalMemoryLimit, int totalMemoryInitLimit,
// int totalMemoryOccupyLimit, boolean color, float timeOutInfo);
/**
* This function will be whenever it's current player's turn, no matter
* there is any available positions for current player or not.
*
* @param chessboard
* Current chessboard, chessboard[x][y] means row y column x
* @param availables
* Available positions for this turn, if there is no available
* position for current player, it will be an empty array (not a
* null pointer).
* @param curStep
* the step number from the beginning
* @param lastMove
* The position which the opponent choose in the last turn, null
* if there is no available postion in the last turn for the
* opponent,
* @return If availables.length>0, the returned value must be an integer
* from 0 to availables.length-1 (inclusive). If
* availables.length==0, the return value can be anything.
*/
abstract public int myTurn(byte[][] chessboard, Point[] availables,
int curStep, Point lastMove);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -