什么是一些具有相当简单的启发式方法来评估位置的游戏?

时间:2022-02-19 11:32:55

I'm teaching a kid programming, and am introducing some basic artificial intelligence concepts at the moment. To begin with we're going to implement a tic-tac-toe game that searches the entire game tree and as such plays perfectly. Once we finish that I want to apply the same concepts to a game that has too many positions to evaluate every single one, so that we need to implement a heuristic to evaluate intermediate positions.

我正在教孩子编程,并且正在介绍一些基本的人工智能概念。首先,我们将实施一个搜索整个游戏树的井字游戏,因此可以完美地播放。一旦我们完成了,我想将相同的概念应用于具有太多位置的游戏来评估每一个,因此我们需要实现一个启发式来评估中间位置。

The best thing I could think of was Dots and Boxes. It has the advantage that I can set the board size arbitrarily large to stop him from searching the entire tree, and I can make a very basic scoring function be the number of my boxes minus the number of opponent boxes. Unfortunately this means that for most of the beginning of the game every position will be evaluated equivalently with a score of 0, because it takes quite a few moves before players actually start making boxes.

我能想到的最好的东西是Dots和Boxes。它的优点是我可以设置任意大的棋盘大小以阻止他搜索整个树,我可以制作一个非常基本的评分函数,即我的盒子数量减去对手盒子的数量。不幸的是,这意味着在游戏开始的大部分时间里,每个位置都会被评分为等分0,因为在玩家真正开始制作盒子之前需要花费很多时间。

Does anyone have any better ideas for games? (Or a better scoring function for dots and boxes)?

有没有人对游戏有更好的想法? (或点和盒子的更好的评分功能)?

12 个解决方案

#1


7  

Another game choice could be Reversi aka Othello.

另一个游戏选择可能是Reversi又名奥赛罗。

A naive heuristic would be to simply count the number of tiles gained by each valid move and choose the greatest. From there you can factor in board position and minimizing vulnerably to the opponent.

一个天真的启发式方法是简单地计算每个有效移动所获得的瓦片数量并选择最大值。从那里你可以考虑到董事会的位置,并最大限度地减少对手的脆弱性。

#2


7  

One game you may consider is Connect Four. Simple game with straightforward rules but more complicated that Tic-Tac-Toe.

您可以考虑的一个游戏是Connect Four。简单的游戏,简单的规则,但更复杂的Tic-Tac-Toe。

#3


3  

Checkers will let you teach several methods. Simple lookahead, depth search of best-case-worst-case decisions, differences between short-term and long-term gains, and something they could continue to work on after learning what you want to teach them.

跳棋会让你教几种方法。简单的前瞻,深度搜索最佳案例 - 最坏情况决策,短期和长期收益之间的差异,以及他们在学习了您想要教授它们之后可以继续努力的事情。

Personally I think that last bit is the most critical -- there are natural points in the AI development which are good to stop at, see if you can beat it, and then delve into deeper AI mechanisms. It keeps your student interested without being horribly frustrated, and gives them more to do on their own if they want to continue the project.

就我个人而言,我认为最后一点是最关键的 - 人工智能开发中有一些自然的点可以很好地停下来,看看你是否可以击败它,然后钻研更深入的AI机制。它让学生感兴趣而不会感到非常沮丧,如果他们想继续这个项目,他们可以自己做更多的事情。

#4


2  

How about Reversi? It has a pretty nice space of heuristics based on number of pieces, number of edge pieces, and number of corner pieces.

黑白棋怎么样?根据件数,边缘件数和角件数量,它具有非常好的启发式空间。

#5


2  

How about Mancala? Only 6 possible moves each turn, and it's easy to calculate the resulting score for each, but it's important to consider the opponent's response, and the game tree gets big pretty fast.

曼卡拉怎么样?每回合只有6次可能的移动,并且很容易计算每个得分,但重要的是要考虑对手的反应,并且游戏树变得非常快。

#6


2  

Gomoku is a nice, simple game, and fun one to write AI for.

Gomoku是一个很好的,简单的游戏,有趣的人写AI。

#7


2  

Rubik's Infinity's quite fun, it's a little bit like Connect Four but subtly different. Evauluating a position is pretty easy.

Rubik的无限非常有趣,它有点像Connect Four,但略有不同。获得一个位置非常容易。

I knocked together a Perl script to play it a while back, and actually had to reduce the number of moves ahead it looked, or it beat me every time, usually with quite surprising tactics.

我把一个Perl剧本拼凑起来玩了一会儿,实际上不得不减少它前面的移动次数,或者每次都击败我,通常用相当惊人的战术。

#8


1  

Four in a line Hard enough, but easy enough to come up with an easy working evaluation function, for example, (distance to four from my longest line - distance to four from my opponent's longest line)

四条线条足够硬,但很容易想出一个简单的工作评估功能,例如,(从我最长的线到四个距离 - 从我对手的最长线到四个距离)

#9


1  

I really like Connect Four. Very easy to program using a Minimax algorithm. A good evaluation function could be:

我真的很喜欢Connect Four。使用Minimax算法很容易编程。一个好的评估功能可能是:

eval_score = 0
for all possible rows/lines/diagonals of length 4 on the board:
    if (#player_pieces = 0) // possible to connect four here?
        if (#computer_pieces = 4)
            eval_score = 10000
            break for loop
        else
            eval_score = eval_score + #computer_pieces
            (less pieces to go -> higher score)
        end if
    else if (#player_pieces = 4)
        eval_score = -10000
        break for loop
    end if
end for

To improve the program you can add:

要改进程序,您可以添加:

  1. If computer moves first, play in the middle column (this has been proven to be optimal)
  2. 如果计算机先移动,请在中间列播放(这已被证明是最佳的)

  3. Alpha-Beta Pruning
  4. Move Ordering
  5. Zobrist Hashes

#10


0  

How about starting your Dots and Boxes game with random lines already added. This can get you into the action quickly. Just need to make sure you don't start the game with any boxes.

如何使用已添加的随机线开始您的Dots and Boxes游戏。这可以让您快速进入行动。只需要确保你不用任何盒子开始游戏。

#11


0  

Take a look at Go.

看看Go吧。

  • Simple enough for kid on very small boards.
  • 对于非常小的板上的孩子来说足够简单。

  • Complexity scales infinitely.
  • 复杂性无限扩展。

  • Has a lot of available papers, algorithms and programs to use either as a scale or basis.
  • 有许多可用的论文,算法和程序可用作规模或基础。

Update: reversi was mentioned, which is a simplified variant of Go. Might be a better choice.

更新:提到了reversi,这是Go的简化版本。可能是一个更好的选择。

#12


0  

In regards to a better heuristic for dots and boxes, I suggest looking at online strategy guides for the game. The first result on Google for "dots and boxes strategy" is quite helpful.

关于点和盒子的更好的启发式,我建议查看游戏的在线策略指南。 Google针对“点和盒策略”的第一个结果非常有用。

Knowing how to use the chain rule separates an OK player from a good one. Knowing when the chain rule will work against you is what separates the best players from the good ones.

知道如何使用链规则将OK玩家与好玩家区分开来。知道链条规则何时会对你起作用是最好的球员和好的球员之间的区别。

#1


7  

Another game choice could be Reversi aka Othello.

另一个游戏选择可能是Reversi又名奥赛罗。

A naive heuristic would be to simply count the number of tiles gained by each valid move and choose the greatest. From there you can factor in board position and minimizing vulnerably to the opponent.

一个天真的启发式方法是简单地计算每个有效移动所获得的瓦片数量并选择最大值。从那里你可以考虑到董事会的位置,并最大限度地减少对手的脆弱性。

#2


7  

One game you may consider is Connect Four. Simple game with straightforward rules but more complicated that Tic-Tac-Toe.

您可以考虑的一个游戏是Connect Four。简单的游戏,简单的规则,但更复杂的Tic-Tac-Toe。

#3


3  

Checkers will let you teach several methods. Simple lookahead, depth search of best-case-worst-case decisions, differences between short-term and long-term gains, and something they could continue to work on after learning what you want to teach them.

跳棋会让你教几种方法。简单的前瞻,深度搜索最佳案例 - 最坏情况决策,短期和长期收益之间的差异,以及他们在学习了您想要教授它们之后可以继续努力的事情。

Personally I think that last bit is the most critical -- there are natural points in the AI development which are good to stop at, see if you can beat it, and then delve into deeper AI mechanisms. It keeps your student interested without being horribly frustrated, and gives them more to do on their own if they want to continue the project.

就我个人而言,我认为最后一点是最关键的 - 人工智能开发中有一些自然的点可以很好地停下来,看看你是否可以击败它,然后钻研更深入的AI机制。它让学生感兴趣而不会感到非常沮丧,如果他们想继续这个项目,他们可以自己做更多的事情。

#4


2  

How about Reversi? It has a pretty nice space of heuristics based on number of pieces, number of edge pieces, and number of corner pieces.

黑白棋怎么样?根据件数,边缘件数和角件数量,它具有非常好的启发式空间。

#5


2  

How about Mancala? Only 6 possible moves each turn, and it's easy to calculate the resulting score for each, but it's important to consider the opponent's response, and the game tree gets big pretty fast.

曼卡拉怎么样?每回合只有6次可能的移动,并且很容易计算每个得分,但重要的是要考虑对手的反应,并且游戏树变得非常快。

#6


2  

Gomoku is a nice, simple game, and fun one to write AI for.

Gomoku是一个很好的,简单的游戏,有趣的人写AI。

#7


2  

Rubik's Infinity's quite fun, it's a little bit like Connect Four but subtly different. Evauluating a position is pretty easy.

Rubik的无限非常有趣,它有点像Connect Four,但略有不同。获得一个位置非常容易。

I knocked together a Perl script to play it a while back, and actually had to reduce the number of moves ahead it looked, or it beat me every time, usually with quite surprising tactics.

我把一个Perl剧本拼凑起来玩了一会儿,实际上不得不减少它前面的移动次数,或者每次都击败我,通常用相当惊人的战术。

#8


1  

Four in a line Hard enough, but easy enough to come up with an easy working evaluation function, for example, (distance to four from my longest line - distance to four from my opponent's longest line)

四条线条足够硬,但很容易想出一个简单的工作评估功能,例如,(从我最长的线到四个距离 - 从我对手的最长线到四个距离)

#9


1  

I really like Connect Four. Very easy to program using a Minimax algorithm. A good evaluation function could be:

我真的很喜欢Connect Four。使用Minimax算法很容易编程。一个好的评估功能可能是:

eval_score = 0
for all possible rows/lines/diagonals of length 4 on the board:
    if (#player_pieces = 0) // possible to connect four here?
        if (#computer_pieces = 4)
            eval_score = 10000
            break for loop
        else
            eval_score = eval_score + #computer_pieces
            (less pieces to go -> higher score)
        end if
    else if (#player_pieces = 4)
        eval_score = -10000
        break for loop
    end if
end for

To improve the program you can add:

要改进程序,您可以添加:

  1. If computer moves first, play in the middle column (this has been proven to be optimal)
  2. 如果计算机先移动,请在中间列播放(这已被证明是最佳的)

  3. Alpha-Beta Pruning
  4. Move Ordering
  5. Zobrist Hashes

#10


0  

How about starting your Dots and Boxes game with random lines already added. This can get you into the action quickly. Just need to make sure you don't start the game with any boxes.

如何使用已添加的随机线开始您的Dots and Boxes游戏。这可以让您快速进入行动。只需要确保你不用任何盒子开始游戏。

#11


0  

Take a look at Go.

看看Go吧。

  • Simple enough for kid on very small boards.
  • 对于非常小的板上的孩子来说足够简单。

  • Complexity scales infinitely.
  • 复杂性无限扩展。

  • Has a lot of available papers, algorithms and programs to use either as a scale or basis.
  • 有许多可用的论文,算法和程序可用作规模或基础。

Update: reversi was mentioned, which is a simplified variant of Go. Might be a better choice.

更新:提到了reversi,这是Go的简化版本。可能是一个更好的选择。

#12


0  

In regards to a better heuristic for dots and boxes, I suggest looking at online strategy guides for the game. The first result on Google for "dots and boxes strategy" is quite helpful.

关于点和盒子的更好的启发式,我建议查看游戏的在线策略指南。 Google针对“点和盒策略”的第一个结果非常有用。

Knowing how to use the chain rule separates an OK player from a good one. Knowing when the chain rule will work against you is what separates the best players from the good ones.

知道如何使用链规则将OK玩家与好玩家区分开来。知道链条规则何时会对你起作用是最好的球员和好的球员之间的区别。