AI策略五子棋(的井字游戏的变化)五子、策略、游戏、AI

2023-09-11 03:07:05 作者:旧琴破碎

我在写一个游戏,是的五子棋的一个变种。基本上是一个井字游戏在一个巨大的板。

I'm writing a game that's a variant of Gomoku. Basically a tic tac toe on a huge board.

想知道如果有谁知道一个良好的AI战略游戏。我目前的实现是非常愚蠢的,需要很长的时间(为O(n ^ 3),约1-2次,使一招):

Wondering if anyone knows a good AI strategy for the game. My current implementation is very stupid and takes a long time (O(n^3), approx 1-2 second to make a move):

-(void) moveAI {
    //check if the enemy is trying to make a line horizontally, vertically, or diagonally
    //O(n^3 * 3)
    [self checkEnemies];

    //check if we can make a line horizontally, vertically, or diagonally
    //O(n^3 * 3)
    [self checkIfWeCanMakeALine];

    //otherwise just put the piece randomly
    [self put randomly];
}

编辑:感谢所有的反馈!我会想你的答案,让你们知道我是否可以作出改善。

Thanks all for the feedback! I'll be trying out your answers and let you guys know if I can make any improvements.

推荐答案

有关五子棋,获胜的策略已被发现。请参阅本文: L.维克托·阿利斯,HJ范登Herik,MPH Huntjens。五子棋和威胁空间搜索。它帮助我,当我书面方式我自己的程序很多。你就可以编写程序,在攻击对手,并找到最佳组合非常好这种方式。

For gomoku, winning strategy has been already found. See this paper: L. Victor Allis, H. J. van den Herik, M. P. H. Huntjens. Go-Moku and Threat-Space Search. It helped me a lot when I was writting my own program. This way you'll be able to write program which is very good in attacking the opponent and finding winning combinations.