⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aithread.java

📁 Java五子棋 支持本地游戏
💻 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 + -