抽象策略博弈的评价函数

发布于 2024-10-05 09:37:41 字数 1573 浏览 4 评论 0原文

我正在使用 C# 和 C# 编写一个抽象策略游戏。 XNA。至于AI,我目前使用的是Negascout,深度为5。以下是游戏的描述:

游戏由一块6x7六角形位置的棋盘、42个六角形瓷砖和6个棋子(1个国王和5个棋子)组成。每个玩家(最多 2 名玩家)。

在游戏的第一阶段,玩家轮流在棋盘的空位置上随机放置一块棋子。每个图块最多可以有 6 个指向边缘的箭头。有些箭头可以是双尖的。箭头表示从该图块开始的移动方向。如果存在有效位置,双头箭头会使棋子移动/跳跃 2 个位置。如果棋盘上还有空位,则玩家不得将棋子放置在对手的行中。

一旦该阶段完成,下一位玩家将依次将他的国王放置在距离他最近的一排 6 块瓷砖中的任意一块上。接下来,棋子开始移动。棋子根据图块上的箭头移动。通过捕获或阻止国王来赢得游戏。

好的,现在介绍我的移动生成函数。

  1. 瓷砖放置阶段 a) 在最近的一行上放置一块图块。旋转瓷砖以找到最佳旋转。 b) 一旦最近的一排已满,将一块棋子放置在四面都被位置包围的空位置上(即没有棋盘边缘)。旋转瓷砖以找到最佳旋转。 c) 如果没有找到位置,则添加所有剩余的空位置,尝试找到最佳旋转。

  2. 国王安置阶段 a) 找到最好的图块位置并将国王放置在那里。 b) 将剩余的棋子放置在该行剩余的空位置上。

  3. 运动阶段 a) 如果王受到攻击,如果攻击方没有防御,则尝试攻击该方。 b) 为所有被攻击的玩家棋子添加动作。 c) 添加玩家可以攻击的所有对手棋子。 d) 添加玩家可以移动到的所有位置。

现在讨论评估函数。

  1. 瓷砖放置阶段 分数 = 当前玩家目前放置的棋子数量 + 当前玩家最近一行的棋子 - 数量。对手目前放置的棋子数量 - 最远行(最接近对手)的对手棋子。

  2. 国王安置阶段 分数 = 当前玩家最近排的牌 - 对手最远排(距离对手最近)的牌。

  3. 运动阶段 得分=当前己方棋子值-对手棋子值。

对于箭头指向的每个有效位置,图块的权重为 100。棋子的权重如下:

棋子价值 = 棋子类型(王 = 10000,兵 = 1000)+ 移动性 + 防御 - 攻击 - 攻击 - 阻挡

其中: 流动性=否。节点可以移动到的位置数(空闲或被对手占领)* 1000 辩护=不。当前玩家围绕该棋子实际可以移动到该位置的棋子数量 * 1000 受到攻击=不。该棋子周围实际可以移动到该位置的对手棋子的数量 * 1000 blocked = (king = -10000, pawn = -1000) 棋子无法移动,因为所有箭头都指向无效位置,并且棋子在本游戏中没有机会再次移动。

很长,但我的问题来了:

  1. 放置图块时,AI 有时会使用错误的旋转来放置图块(即将图块放置在箭头指向无效位置的位置)。有时这种情况发生在他的“主”行中。

  2. 移动棋子时,人工智能会忽略国王的安全。主要移动国王,并在大约 4-6 步内被捕获。

任何人,尤其是具有国际象棋人工智能经验的人,对如何改进我的人工智能,特别是我的移动生成和评估功能有想法和建议吗?

谢谢 顺便说一句,伊万

...如果有人有兴趣尝试邮件,请告诉我,我将在我的网站上上传设置。

I'm coding an abstract strategy game with C# & XNA. As for the AI, I'm currently using Negascout and a depth of 5. The following is the description of the game:

The game consists of a board of 6x7 hexagonal locations, 42 hexagonal tiles, and 6 pieces (1 king & 5 pawns) for each player (max 2 players).

During the first phase of the game, the players alternately place a random tile on an empty location of the board. Each tile can have a maximum of 6 arrows pointing at the edges. Some arrows can be double-pointed. The arrows mean the direction/s of movement from that tile. A double-pointed arrow makes a piece move/jump 2 locations if there's a valid location. The players are not allowed to place tiles in their opponent's row if there are still empty locations left on the board.

Once this phase is complete, the next player in turn places his king on any one of the 6 tiles of the row nearest to him. Next, the movement of the pieces commences. Pieces are moved according to the arrows on the tiles. The game is won by capturing or blocking the king.

Ok, so now to my move generation function.

  1. Tile placement stage
    a) Place a tile on the nearest row. The tile is rotated to find the optimal rotation.
    b) Once the nearest row is full, place a tile on an empty location that is surrounded by locations on all sides (ie no edge of board). Rotate the tile to find the optimal rotation.
    c) If no locations are found, add all remaining empty locations, trying to find the optimal rotation.

  2. King placement stage
    a) Locate the location with the best tile and place the king there.
    b) Place the remaining pawns on the remaining empty locations on the row.

  3. Movement stage
    a) If king is attacked, try to attack the attacking piece if that piece is not defended.
    b) Add moves for all player's pieces that are being attacked.
    c) Add all opponent pieces that the player can attack.
    d) Add all locations player can move to.

Now to the evaluation function.

  1. Tile placement stage
    score = No. of tiles current player placed so far + current player's tiles on the nearest row - no. of tiles opponent placed so far - opponent's tiles on the furthest row (nearest to the opponent).

  2. King placement stage
    score = current player's tiles on the nearest row - opponent's tiles on the furthest row (nearest to the opponent).

  3. Movement stage
    score = current player's pieces' value - opponent's pieces' value.

The weighting of the tiles is 100 for every valid location an arrow points to. The weighting of the pieces is as follows:

piece value = piece type (king = 10000, pawn = 1000) + mobility + defended - attacked - enprise - blocked

where:
mobilty = no. of locations node can move to (free or occupied by the opponent) * 1000
defended = no. of current player pieces surrounding this piece that can actually move to this location * 1000
attacked = no. of opponent pieces surrounding this piece that can actually move to this location * 1000
blocked = (king = -10000, pawn = -1000) piece cannot move because all arrows point to invalid locations and the piece has no chance of moving again in this game.

Quite long, but here come my problems:

  1. When placing tiles, the AI sometimes places a tile using the wrong rotation (ie. places a tile in location where the arrows point to no valid locations). Sometimes this occurs in his 'home' row.

  2. When moving pieces, the AI is ignoring king safety. Moves mostly the king and is captured in about 4-6 moves.

Anybody, especially with chess AI experience, has ideas and suggestions on how to improve my AI, in particular my move generation and evaluation functions?

Thanks
Ivan

btw... If anyone is interested in trying out the mail, just let me know and I'll upload a setup on my website.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山色无中 2024-10-12 09:37:41

很长,但我的问题来了:

确实很长。

放置图块时,AI 有时会使用错误的旋转来放置图块(即将图块放置在箭头指向无效位置的位置)。有时这种情况发生在他的“主”行。

换句话说,您的代码中有错误。即使有如此详尽的序言,也无法回答这个问题。这个问题应该是一个单独的、措辞简洁的问题,其中包括相关代码的副本。

移动棋子时,人工智能会忽略国王的安全。主要移动国王并在大约 4-6 步内被捕获。

与上面相同。即使根据您写的详尽的序言也无法回答这个问题。

我给您的建议是,您的问题要更加简洁,仅发布与问题相关的详细信息,而不是将多个问题合并到一个帖子中。

任何人,尤其是具有国际象棋人工智能经验的人,对如何改进我的人工智能,特别是我的移动生成和评估功能有想法和建议吗?

这是一个过于模糊的问题,通常会被关闭。如果您需要一些有关代码的建议,您必须提供该代码,以便任何人都能为您提供超越盲目猜测的有用答案!

Quite long, but here come my problems:

Quite long, indeed.

When placing tiles, the AI sometimes places a tile using the wrong rotation (ie. places a tile in location where the arrows point to no valid locations). Sometimes this occurs in his 'home' row.

In other words, you have a bug in your code. There's no way to answer this question, even with all this extensive preamble. This question should be in a separate, concisely-phrased question that includes a copy of the relevant code.

When moving pieces, the AI is ignoring king safety. Moves mostly the king and is captured in about 4-6 moves.

Same as above. This question can't be answered based on even the extensive preamble you've written.

My advice to you is to be more concise with your questions, post only the details relevant to the problem, and not to combine multiple questions into a single post.

Anybody, especially with chess AI experience, has ideas and suggestions on how to improve my AI, in particular my move generation and evaluation functions?

This is an overly vague question that would normally get closed. If you want some advice about your code, you would have to provide that code in order for anyone to give you a helpful answer that goes beyond blind speculation!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文