📄 aithread.java
字号:
import java.io.IOException;
/**
*
* this class creates a thread for a computer player
*
*/
class AIThread extends Thread
{
Player computerPlayer;
ChessGame game;
//the search engine of the computer player
SearchEngine engine;
AIThread(ChessGame game)
{
this.game = game;
this.computerPlayer = game.notLocalPlayer;
engine = new AlphaBetaEngine(game.mapSize, 2);
}
public void run()
{
//loop until game is over
while(game.status != GameStatus.Over)
{
//see if its computer's turn
if(this.computerPlayer != game.activePlayer)
{
this.suspend();
continue;
}
//search a move
engine.searchAGoodMove(game.chessMap, computerPlayer.chessMan);
ChessPos pos = engine.bestMove;
//play chess
game.playChess(pos.x, pos.y);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -