全部版块 我的主页
论坛 数据科学与人工智能 IT基础
31 0
2025-11-16

创建 Blazor Web 工程,选择 Auto

[此处为图片1]

打开 GitHub Copilot 窗口,输入提示词

使用 Blazor 编写一个五子棋游戏

[此处为图片2]

为了便于调试,我们将运行模式从 InteractiveAuto 更改为 InteractiveServer

打开 App.razor 文件,将两行 @rendermode="InteractiveAuto" 修改为 @rendermode="InteractiveServer"

[此处为图片3]

不出所料,代码出现了问题

[此处为图片4]

尝试用 AI 自动修复问题

[此处为图片5]

结果发现这不是问题所在。问题出在逻辑代码 @onclick="() => PlacePiece(x, y)" 上。原因是 PlacePiece 闭包捕获了当前循环的 x、y 值。

既然已经手动找到了问题,我们再次提示 AI 尝试修复

[此处为图片6]

最终还是没有修复成功,只能手动处理

@page "/"
五子棋
五子棋游戏
当前玩家:
@(currentPlayer == 1 ? "黑子" : "白子")
@if (winner != 0)
{
胜者: @(winner == 1 ? "黑子" : "白子")
重新开始
}
@for (int y = 0; y < BoardSize; y++)
{
@for (int x = 0; x < BoardSize; x++)
{
int _x = x;
int _y = y;
}
}
@onclick="@(() => PlacePiece(_x, _y))">
@if (board[x, y] == 1)
{
●
}
else if (board[x, y] == 2)
{
●
}
@code {
const int BoardSize = 15;
int[,] board = new int[BoardSize, BoardSize];
int currentPlayer = 1; // 1: 黑子, 2: 白子
int winner = 0;
void PlacePiece(int x, int y)
{
// 修复:增加边界检查,防止越界
if (x < 0 || x >= BoardSize || y < 0 || y >= BoardSize)
return;
if (winner != 0 || board[x, y] != 0)
return;
board[x, y] = currentPlayer;
if (CheckWin(x, y, currentPlayer))
{
winner = currentPlayer;
}
else
{
currentPlayer = 3 - currentPlayer; // 切换玩家
}
}
bool CheckWin(int x, int y, int player)
{
int[][] directions = new int[][]
{
new int[]{1,0}, // 横
new int[]{0,1}, // 竖
new int[]{1,1}, // 斜
new int[]{1,-1} // 反斜
};
foreach (var dir in directions)
{
int count = 1;
count += CountDirection(x, y, dir[0], dir[1], player);
count += CountDirection(x, y, -dir[0], -dir[1], player);
if (count >= 5)
return true;
}
return false;
}
int CountDirection(int x, int y, int dx, int dy, int player)
{
int count = 0;
for (int step = 1; step < 5; step++)
{
int nx = x + dx * step;
int ny = y + dy * step;
if (nx < 0 || nx >= BoardSize || ny < 0 || ny >= BoardSize)
break;
if (board[nx, ny] == player)
count++;
else
break;
}
return count;
}
void Restart()
{
board = new int[BoardSize, BoardSize];
currentPlayer = 1;
winner = 0;
}
string GetCellBg(int x, int y)
{
return (x + y) % 2 == 0 ? "#f9d77e" : "#eac066";
}
}

说明:

添加 int _x = x; int _y = y; 确保闭包捕获的 _x_y 是当前循环的值,避免 Blazor 渲染时闭包变量引用出错。

PlacePiece 方法起始处增加边界检查,防止非法坐标引发数组越界异常。

如此可以彻底修正 PlacePiece 获取的变量不准确和越界的问题。

5. 运行效果
[此处为图片1]
6. 增设显示当前玩家的得分功能

可以为每位玩家增设一个得分变量,每当有玩家获胜时增加其得分,并在界面中展示。以下是具体实现步骤:

@code 区域添加得分字段:

int blackScore = 0;
int whiteScore = 0;

在玩家获胜时更新得分:

void PlacePiece(int x, int y)
{
if (x < 0 || x >= BoardSize || y < 0 || y >= BoardSize)
return;
if (winner != 0 || board[x, y] != 0)
return;
board[x, y] = currentPlayer;
if (CheckWin(x, y, currentPlayer))
{
winner = currentPlayer;
if (winner == 1)
blackScore++;
else if (winner == 2)
whiteScore++;
}
else
{
currentPlayer = 3 - currentPlayer; // 更换玩家
}
}

在页面上显示得分(如在标题下方):

当前玩家:
@(currentPlayer == 1 ? "黑子" : "白子")
黑子得分:
@blackScore
白子得分:
@whiteScore
@if (winner != 0)
{
胜者: @(winner == 1 ? "黑子" : "白子")
重新开始
}

如此每次有玩家获胜时,得分会自动更新并在页面上显示。

[此处为图片1]
7. 增设重置得分功能

你可以在 Restart 方法中加入对得分的重置,或单独添加一个“重置得分”按钮和方法。推荐操作如下:

添加重置得分方法:

void ResetScore()
{
blackScore = 0;
whiteScore = 0;
}

在页面上添加按钮:

重置得分

建议将此按钮置于得分显示附近,例如:

当前玩家:
@(currentPlayer == 1 ? "黑子" : "白子")
黑子得分:
@blackScore
白子得分:
@whiteScore
重置得分
@if (winner != 0)
{
胜者: @(winner == 1 ? "黑子" : "白子")
重新开始
}

如此点击“重置得分”按钮即可将得分归零。

8. 在这个五子棋游戏中添加 AI 对手功能

在你的 Blazor 五子棋游戏中添加 AI 对手功能,通常做法是让一方(如白子)由 AI 自动落子。实现策略如下:

判断当前玩家是否为 AI:如 currentPlayer == 2 时,自动调用 AI 落子逻辑。

实现 AI 落子算法:可以先采用简单的随机落子,后续可拓展为更智能的算法。

在玩家落子后自动触发 AI 落子:使用 StateHasChanged() 刷新界面,必要时使用 await Task.Delay() 添加落子延迟。

以下是具体实现方法(以白子为 AI):

@page "/"
五子棋
五子棋游戏
当前玩家:
@(currentPlayer == 1 ? "黑子" : "白子(电脑)")
黑子得分:
@blackScore
白子得分:
@whiteScore
重置得分
@if (winner != 0)
{
胜者: @(winner == 1 ? "黑子" : "白子(电脑)")
重新开始
}
@for (int y = 0; y < BoardSize; y++)
{
@for (int x = 0; x < BoardSize; x++)
{
int _x = x;
int _y = y;
}
}
@onclick="@(() => PlacePiece(_x, _y))">
@if (board[x, y] == 1)
{
●
}
else if (board[x, y] == 2)
{
●
}
@code {
const int BoardSize = 15;
int[,] board = new int[BoardSize, BoardSize];
int currentPlayer = 1; // 1: 黑子, 2: 白子(电脑)
int winner = 0;
int blackScore = 0;
int whiteScore = 0;
Random rand = new();

if (winner != 0 || board[x, y] != 0 || currentPlayer == 2) return;

board[x, y] = currentPlayer;

if (CheckWin(x, y, currentPlayer))

{

winner = currentPlayer;

if (winner == 1)

blackScore++;

else if (winner == 2)

whiteScore++;

}

else

{

currentPlayer = 2;

StateHasChanged();

_ = AITurnAsync();

}

}

async Task AITurnAsync()

{

await Task.Delay(500); // AI 落子延迟

if (winner != 0) return;

// 简单随机落子

var empty = new List<(int x, int y)>();

for (int i = 0; i < BoardSize; i++)

for (int j = 0; j < BoardSize; j++)

if (board[i, j] == 0)

empty.Add((i, j));

if (empty.Count == 0) return;

var (aiX, aiY) = empty[rand.Next(empty.Count)];

board[aiX, aiY] = 2;

if (CheckWin(aiX, aiY, 2))

{

winner = 2;

whiteScore++;

}

else

{

currentPlayer = 1;

}

StateHasChanged();

}

// 其余代码不变...

bool CheckWin(int x, int y, int player)

{

int[][] directions = new int[][]

{

new int[]{1,0}, new int[]{0,1}, new int[]{1,1}, new int[]{1,-1}

};

foreach (var dir in directions)

{

int count = 1;

count += CountDirection(x, y, dir[0], dir[1], player);

count += CountDirection(x, y, -dir[0], -dir[1], player);

if (count >= 5)

return true;

}

return false;

}

int CountDirection(int x, int y, int dx, int dy, int player)

{

int count = 0;

for (int step = 1; step < 5; step++)

{

int nx = x + dx * step;

int ny = y + dy * step;

if (nx < 0 || nx >= BoardSize || ny < 0 || ny >= BoardSize)

break;

if (board[nx, ny] == player)

count++;

else

break;

}

return count;

}

void Restart()

{

board = new int[BoardSize, BoardSize];

currentPlayer = 1;

winner = 0;

}

void ResetScore()

{

blackScore = 0;

whiteScore = 0;

}

string GetCellBg(int x, int y)

{

return (x + y) % 2 == 0 ? "#f9d77e" : "#eac066";

}

}

要点说明:

玩家(黑子)下棋后自动触发 AI(白子)下棋。

AI 采取随机空位下棋,简易直观,未来可升级为更智能的算法。

若要让 AI 先手,只需将 currentPlayer = 2 并在 OnInitialized 或 Restart 时调用 AITurnAsync()。

[此处为图片1]

用是可以用了, 只是这个AI太初级了, 需要进一步优化

要优化五子棋 AI 的下棋策略,可以使用“优先级评分法”来增加挑战性。基本思路如下:

首先考虑可以直接获胜的位置(例如 AI 连成五子)。

阻止对手获胜(例如对手有四连,AI 必须封堵)。

优先进攻(例如自己有三连、二连)。

其次防守(例如对手有三连、二连)。

否则随机选择或选择评分最高的位置。

以下是一个简单的评分法实现,AI 会优先选择能赢、能防、能攻的位置:

async Task AITurnAsync()

{

await Task.Delay(500);

if (winner != 0) return;

var (aiX, aiY) = FindBestMove();
board[aiX, aiY] = 2;
if (CheckWin(aiX, aiY, 2))
{
winner = 2;
whiteScore++;
}
else
{
currentPlayer = 1;
}
StateHasChanged();
}
// 简单评估策略:首要取胜、阻击对手、发起攻势
(int, int) FindBestMove()
{
int maxScore = int.MinValue;
var bestMoves = new List<(int x, int y)>();
for (int x = 0; x < BoardSize; x++)
{
for (int y = 0; y < BoardSize; y++)
{
if (board[x, y] != 0) continue;
int score = EvaluatePoint(x, y, 2); // AI攻势
score = Math.Max(score, EvaluatePoint(x, y, 1)); // 阻挡
if (score > maxScore)
{
maxScore = score;
bestMoves.Clear();
bestMoves.Add((x, y));
}
else if (score == maxScore)
{
bestMoves.Add((x, y));
}
}
}
// 若有多个最佳点则随机选取
return bestMoves[rand.Next(bestMoves.Count)];
}
// 评估函数:根据实际情况调整权重
int EvaluatePoint(int x, int y, int player)
{
int score = 0;
int opponent = player == 1 ? 2 : 1;
// 检查连续四个、三个、两个等
foreach (var dir in new[] { (1, 0), (0, 1), (1, 1), (1, -1) })
{
int count = 1 + CountDirection(x, y, dir.Item1, dir.Item2, player)
+ CountDirection(x, y, -dir.Item1, -dir.Item2, player);
if (count >= 5) score += 10000; // 直接胜出
else if (count == 4) score += 1000;
else if (count == 3) score += 100;
else if (count == 2) score += 10;
// 防守得分
int oppCount = 1 + CountDirection(x, y, dir.Item1, dir.Item2, opponent)
+ CountDirection(x, y, -dir.Item1, -dir.Item2, opponent);
if (oppCount >= 5) score += 9000; // 必须防守
else if (oppCount == 4) score += 900;
else if (oppCount == 3) score += 90;
else if (oppCount == 2) score += 9;
}
return score;
}
集成方式:
将你的 AITurnAsync 方法替换为上述实现。
在 @code 区域加入 FindBestMove 和 EvaluatePoint 方法。
可依据实际效果调整评分权重。
功能描述:
AI 将首先选择能够取胜的位置,其次是阻止玩家形成四连,再次是考虑攻击和防御三连、二连。
这种评估策略简洁且高效,能显著提高 AI 的挑战性。
若需增加难度,可以进一步实现“活三”、“活四”识别、双向评估、乃至 Minimax 算法。
image
9. 添加难度切换按钮
添加三种难度选项按钮及切换人机对战按钮
以下是实现“三个难度选择按钮(简易、标准、困难)”和“人机/人人对战切换按钮”的完整方法。
难度通过调节 AI 的评分权重来实现,人机切换通过 isHumanVsAI 控制。请直接替换你的 Home.razor 文件内容:
@page "/"
五子棋
五子棋游戏
难度:
简易
标准
困难
模式:
@(isHumanVsAI ? "人机对决" : "人人对决")
当前玩家:
@(currentPlayer == 1 ? "黑棋" : (isHumanVsAI ? "白棋(电脑)" : "白棋"))
黑棋得分:
@blackScore
白棋得分:
@whiteScore
重置得分
@if (winner != 0)
{
    
胜者: @(winner == 1 ? "黑子" : (isHumanVsAI ? "白子(电脑)" : "白子")) 重新开始 } @for (int y = 0; y < BoardSize; y++) { @for (int x = 0; x < BoardSize; x++) { int _x = x; int _y = y; } } @onclick="@(() => PlacePiece(_x, _y))"> @if (board[x, y] == 1) { ● } else if (board[x, y] == 2) { ● } @code { const int BoardSize = 15; int[,] board = new int[BoardSize, BoardSize]; int currentPlayer = 1; // 1: 黑子, 2: 白子(电脑/玩家) int winner = 0; int blackScore = 0; int whiteScore = 0; Random rand = new(); bool isHumanVsAI = true; int aiLevel = 1; // 0:简单 1:中等 2:困难 void PlacePiece(int x, int y) { if (winner != 0 || board[x, y] != 0) return; // 人机模式下,只有当前为玩家时可落子 if (isHumanVsAI && currentPlayer == 2) return; board[x, y] = currentPlayer; if (CheckWin(x, y, currentPlayer)) { winner = currentPlayer; if (winner == 1) blackScore++; else if (winner == 2) whiteScore++; } else { currentPlayer = 3 - currentPlayer; if (isHumanVsAI && currentPlayer == 2 && winner == 0) { StateHasChanged(); _ = AITurnAsync(); } } } async Task AITurnAsync() { await Task.Delay(500); if (winner != 0) return; var (aiX, aiY) = FindBestMove(); board[aiX, aiY] = 2; if (CheckWin(aiX, aiY, 2)) { winner = 2; whiteScore++; } else { currentPlayer = 1; } StateHasChanged(); } (int, int) FindBestMove() { if (aiLevel == 0) { // 简单:随机落子 var empty = new List<(int x, int y)>(); for (int i = 0; i < BoardSize; i++) for (int j = 0; j < BoardSize; j++) if (board[i, j] == 0) empty.Add((i, j)); return empty[rand.Next(empty.Count)]; } else { // 中等/困难:评分法 int maxScore = int.MinValue; var bestMoves = new List<(int x, int y)>(); for (int x = 0; x < BoardSize; x++) { for (int y = 0; y < BoardSize; y++) { if (board[x, y] != 0) continue; int score = EvaluatePoint(x, y, 2); score = Math.Max(score, EvaluatePoint(x, y, 1)); if (score > maxScore) { maxScore = score; bestMoves.Clear(); bestMoves.Add((x, y)); } else if (score == maxScore) { bestMoves.Add((x, y)); } } } return bestMoves[rand.Next(bestMoves.Count)]; } } int EvaluatePoint(int x, int y, int player) { int score = 0; int opponent = player == 1 ? 2 : 1; ```
// 各种难度的权重值
int[] winWeight = { 100, 10000, 10000 };
int[] fourWeight = { 10, 1000, 3000 };
int[] threeWeight = { 5, 100, 500 };
int[] twoWeight = { 2, 10, 50 };
int[] blockWinWeight = { 90, 9000, 9000 };
int[] blockFourWeight = { 9, 900, 2500 };
int[] blockThreeWeight = { 4, 90, 400 };
int[] blockTwoWeight = { 1, 9, 40 };
foreach (var dir in new[] { (1, 0), (0, 1), (1, 1), (1, -1) })
{
    int count = 1 + CountDirection(x, y, dir.Item1, dir.Item2, player)
        + CountDirection(x, y, -dir.Item1, -dir.Item2, player);
    if (count >= 5) score += winWeight[aiLevel];
    else if (count == 4) score += fourWeight[aiLevel];
    else if (count == 3) score += threeWeight[aiLevel];
    else if (count == 2) score += twoWeight[aiLevel];
    int oppCount = 1 + CountDirection(x, y, dir.Item1, dir.Item2, opponent)
        + CountDirection(x, y, -dir.Item1, -dir.Item2, opponent);
    if (oppCount >= 5) score += blockWinWeight[aiLevel];
    else if (oppCount == 4) score += blockFourWeight[aiLevel];
    else if (oppCount == 3) score += blockThreeWeight[aiLevel];
    else if (oppCount == 2) score += blockTwoWeight[aiLevel];
}
return score;
}
bool CheckWin(int x, int y, int player)
{
    int[][] directions = new int[][]
    {
        new int[]{1,0}, new int[]{0,1}, new int[]{1,1}, new int[]{1,-1}
    };
    foreach (var dir in directions)
    {
        int count = 1;
        count += CountDirection(x, y, dir[0], dir[1], player);
        count += CountDirection(x, y, -dir[0], -dir[1], player);
        if (count >= 5)
            return true;
    }
    return false;
}
int CountDirection(int x, int y, int dx, int dy, int player)
{
    int count = 0;
    for (int step = 1; step < 5; step++)
    {
        int nx = x + dx * step;
        int ny = y + dy * step;
        if (nx < 0 || nx >= BoardSize || ny < 0 || ny >= BoardSize)
            break;
        if (board[nx, ny] == player)
            count++;
        else
            break;
    }
    return count;
}
void Restart()
{
    board = new int[BoardSize, BoardSize];
    currentPlayer = 1;
    winner = 0;
    if (isHumanVsAI && currentPlayer == 2)
    {
        _ = AITurnAsync();
    }
}
void ResetScore()
{
    blackScore = 0;
    whiteScore = 0;
}
void SetAILevel(int level)
{
    aiLevel = level;
    Restart();
}
void ToggleMode()
{
    

isHumanVsAI = !isHumanVsAI;

Restart();

}

string GetCellBg(int x, int y)

{

return (x + y) % 2 == 0 ? "#f9d77e" : "#eac066";

}

}

说明:

“简易”AI为随机放置,“中等/复杂”AI为评分方法,复杂级别权重更大,更具有挑战性。

“人机对抗”时白子代表AI,“双人对战”时双方均为参与者。

更改难度或模式将自动重启棋局。

您可根据需求调整权重数组来微调难度。

10. 最后附上完整代码

@page "/"

五子棋

五子棋游戏

难度:

简易

中等

复杂

模式:

@(isHumanVsAI ? "人机对抗" : "双人对战")

当前参与者:

@(currentPlayer == 1 ? "黑子" : (isHumanVsAI ? "白子(计算机)" : "白子"))

黑子得分:

@blackScore

白子得分:

@whiteScore

重置得分

@if (winner != 0)

{

胜者: @(winner == 1 ? "黑子" : (isHumanVsAI ? "白子(计算机)" : "白子"))

重新开始

}

@for (int y = 0; y < BoardSize; y++)

{

@for (int x = 0; x < BoardSize; x++)

{

int _x = x;

int _y = y;

}

}

@onclick="@(() => PlacePiece(_x, _y))">

@if (board[x, y] == 1)

{

}

else if (board[x, y] == 2)

{

}

@code {

const int BoardSize = 15;

int[,] board = new int[BoardSize, BoardSize];

int currentPlayer = 1; // 1: 黑子, 2: 白子(计算机/参与者)

int winner = 0;

int blackScore = 0;

int whiteScore = 0;

Random rand = new();

bool isHumanVsAI = true;

int aiLevel = 1; // 0:简易 1:中等 2:复杂

void PlacePiece(int x, int y)

{

if (winner != 0 || board[x, y] != 0)

return;

// 人机模式下,仅当轮到参与者时才可放置

if (isHumanVsAI && currentPlayer == 2)

return;

board[x, y] = currentPlayer;

if (CheckWin(x, y, currentPlayer))

{

winner = currentPlayer;

if (winner == 1)

blackScore++;

else if (winner == 2)

whiteScore++;

}

else

{

currentPlayer = 3 - currentPlayer;

if (isHumanVsAI && currentPlayer == 2 && winner == 0)

{

StateHasChanged();

_ = AITurnAsync();

}

}

}

async Task AITurnAsync()

{

await Task.Delay(500);

if (winner != 0) return;

var (aiX, aiY) = FindBestMove();

board[aiX, aiY] = 2;

if (CheckWin(aiX, aiY, 2))

{

winner = 2;

whiteScore++;

}

else

{

currentPlayer = 1;

}

StateHasChanged();

}

(int, int) FindBestMove()

{

if (aiLevel == 0)

{

// 简易:随机放置

var empty = new List<(int x, int y)>();

for (int i = 0; i < BoardSize; i++)

for (int j = 0; j < BoardSize; j++)

if (board[i, j] == 0)

empty.Add((i, j));

return empty[rand.Next(empty.Count)];

}

else

{

// 中等/复杂:评分方法

int maxScore = int.MinValue;

var bestMoves = new List<(int x, int y)>();

for (int x = 0; x < BoardSize; x++)

{

for (int y = 0; y < BoardSize; y++)
{
    if (board[x, y] != 0) continue;
    int score = EvaluatePoint(x, y, 2);
    score = Math.Max(score, EvaluatePoint(x, y, 1));
    if (score > maxScore)
    {
        maxScore = score;
        bestMoves.Clear();
        bestMoves.Add((x, y));
    }
    else if (score == maxScore)
    {
        bestMoves.Add((x, y));
    }
}
}
return bestMoves[rand.Next(bestMoves.Count)];
}
}
int EvaluatePoint(int x, int y, int player)
{
    int score = 0;
    int adversary = player == 1 ? 2 : 1;
    // 各种难度下的权重
    int[] winWeight = { 100, 10000, 10000 };
    int[] fourWeight = { 10, 1000, 3000 };
    int[] threeWeight = { 5, 100, 500 };
    int[] twoWeight = { 2, 10, 50 };
    int[] blockWinWeight = { 90, 9000, 9000 };
    int[] blockFourWeight = { 9, 900, 2500 };
    int[] blockThreeWeight = { 4, 90, 400 };
    int[] blockTwoWeight = { 1, 9, 40 };
    foreach (var dir in new[] { (1, 0), (0, 1), (1, 1), (1, -1) })
    {
        int count = 1 + CountDirection(x, y, dir.Item1, dir.Item2, player)
            + CountDirection(x, y, -dir.Item1, -dir.Item2, player);
        if (count >= 5) score += winWeight[aiLevel];
        else if (count == 4) score += fourWeight[aiLevel];
        else if (count == 3) score += threeWeight[aiLevel];
        else if (count == 2) score += twoWeight[aiLevel];
        int oppCount = 1 + CountDirection(x, y, dir.Item1, dir.Item2, adversary)
            + CountDirection(x, y, -dir.Item1, -dir.Item2, adversary);
        if (oppCount >= 5) score += blockWinWeight[aiLevel];
        else if (oppCount == 4) score += blockFourWeight[aiLevel];
        else if (oppCount == 3) score += blockThreeWeight[aiLevel];
        else if (oppCount == 2) score += blockTwoWeight[aiLevel];
    }
    return score;
}
bool CheckWin(int x, int y, int player)
{
    int[][] directions = new int[][]
    {
        new int[]{1,0}, new int[]{0,1}, new int[]{1,1}, new int[]{1,-1}
    };
    foreach (var dir in directions)
    {
        int count = 1;
        count += CountDirection(x, y, dir[0], dir[1], player);
        count += CountDirection(x, y, -dir[0], -dir[1], player);
        if (count >= 5)
            return true;
    }
    return false;
}
int CountDirection(int x, int y, int dx, int dy, int player)
{
    int count = 0;
    for (int step = 1; step < 5; step++)
    {
        int nx = x + dx * step;
        int ny = y + dy * step;
    
if (nx < 0 || nx >= BoardSize || ny < 0 || ny >= BoardSize)
break;
if (board[nx, ny] == player)
count++;
else
break;
}
return count;
}
void Restart()
{
board = new int[BoardSize, BoardSize];
currentPlayer = 1;
winner = 0;
if (isHumanVsAI && currentPlayer == 2)
{
_ = AITurnAsync();
}
}
void ResetScore()
{
blackScore = 0;
whiteScore = 0;
}
void SetAILevel(int level)
{
aiLevel = level;
Restart();
}
void ToggleMode()
{
isHumanVsAI = !isHumanVsAI;
Restart();
}
string GetCellBg(int x, int y)
{
return (x + y) % 2 == 0 ? "#f9d77e" : "#eac066";
}
    
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群