📄 othelloai.java
字号:
// 电脑下棋
class OthelloAI
{
private int color;
public OthelloAI(int c)
{
if (!(c == Cyberthello.WHITE || c == Cyberthello.BLACK))//不是黑子也不是白字
throw new IllegalArgumentException("Invalid value for color: " + c);//抛出错误,落子颜色不对
color = c;//把颜色置成电脑所执的颜色
}
public Move chooseMove(OthelloBoard board)
{
for (int r = 0; r < 8; ++r)
for (int c = 0; c < 8; ++c)
{
Move move = new Move(r, c);
if (board.isValidMove(move, color))
return move;
}
return Move.pass;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -