Search code examples
artificial-intelligenceminmax

How to apply min max algorithm to a hex game


How to design a efficient algorithm for hex game using min max algorithm since its branching factor is too high. Normal tic tac toe game be made using simple min max algorithm but in this case for a 11*11 board game we have 121 combinations so for this how to reduce number of combinations what is the approach minmize this much combination


Solution

  • The tree of movements for a game can only be explore fully for simple stuff like tic-tac-toe. Other games, like chess, will be too deep and have too many options at every movement (large branching factor).

    There are measures to combat this limitation, at the very general level of your question.

    Most importantly, you need a heuristic to assign a value to intermediate game positions. This enables you to apply minimax even if the analysis of all movements up to game endings is not possible. These heuristics may be quite simple. For example, in chess you may give pieces a value (pawn 1, knight 3, and so on) and simply add up. You may make it a bit more complex considering the position on the board and so on, but there will be a compromise with performance here. This is the basis of many AI systems.

    A classic improvement is called alpha-beta pruning. This is based on evaluating the nodes of the tree of movements in an orderly way, so that branches that are already guaranteed to be worse than others can be omitted, improving efficiency. (Consider, for example, a branch where one player can force a winning movement: alternatives to this movement within this branch are not important, since this player will always force the winning movement if the game goes this way).

    Other algorithms change the way we explore the tree of movements. Monte-Carlo tree search is an example of this. The core idea here is to evaluate nodes and explore the tree in a coordinated way (as opposed to before, where we first explore the tree as deep as possible and we then evaluate the leafs). Here we have an exploration-exploitation equilibrium (you have to decide if you want to develop more promising positions, or if you want to favour exploring new, possibly disappointing movements).