Chess: high branching factor

后端 未结 2 1361
無奈伤痛
無奈伤痛 2021-01-30 15:43

I\'m trying to develop a simple chess engine, but I\'m struggling with its performance. I\'ve implemented Negamax with alpha-beta pruning and iterative deepening (without any ad

2条回答
  •  终归单人心
    2021-01-30 16:03

    There is multiple heuristics that you can use to reduce your branching factor.

    First, you should use a transposition table (TT) to store positions results, depth and best move. Before you search a move, you first check if it's already been searched at a depth >= to the depth you are planing to search to. If it is, you can simply use the result from the table. If it's not, you might still use the move in the table as your first move to search.

    If there is no match in the TT for a position (inside the search), you can use Iterative Deepening (ID). Instead of doing a search to a depth of N, you first do a search to a depth of N-2. This will be really fast and will give you a move to search first at depth N.

    There is also Null Move Pruning. In combination with Alpha-Beta (Negamax is a variation on Alpha-Beta) in will greatly reduce your branching factor. The idea is before searching a position, you try a null move (not playing) and do a reduce search (N-2 or N-3). The reduce search will be really fast. If the result of the null move search is still higher than beta it means the position is so bad that you don't need to search it anymore (not always true, but it is most of the time).

    Of course there is multiple others heuristic you can use to improve your move ordering wich will all improve your branching factor.

提交回复
热议问题