优化算法看到谁赢得了蜱TAC脚趾游戏脚趾、算法、赢得了、游戏

2023-09-12 21:21:16 作者:心中满是打伞的路人丶

我有一个完整的井字游戏板。这是3×3,我不是真正的要价code(尽管这将帮助),但什么算法将是最适合看到谁赢了?另一种方法是短语它会是这样,我应该研究什么样的算法,将看到谁赢了是有用的?

I have a completed tic tac toe game board. It is 3 x 3. Im not really asking for code (although that would help), but what algorithms would be best for seeing who won? Another way to phrase it would be, what algorithms should I research that would be useful to see who won?

这真的想到的唯一的事情就是蛮力。只是测试所有的可能性,但我知道必须有一个更好的办法。

The only thing that really comes to mind is brute force. Just test all the possibilities, but I know there has to be a better way.

推荐答案

这是重要的一课我最近在(再)获悉:在搜索空间足够小,就用蛮力。

An important lesson I recently (re-)learned: when the search space is small enough, just use brute force.

在一个3x3板有八种可能获胜序列(行,列和对角线)。这就给了你24比较来验证,如果人有相同的播放器中的所有它的细胞标记。 24比较采取任何时候都连上一个非常缓慢的电脑。

On a 3x3 board there are eight possible winning sequences (the rows, columns, and diagonals.) That gives you 24 comparisons to verify if one has the same player marking in all it cells. 24 comparisons take no time at all even on a very slow computer.