Пишите без рекурсии (псевдокод) используя циклы. function minimax(node, depth, maximizingplayer) is if depth = 0 or node is a terminal node then return the heuristic value of node if maximizingplayer then value : = −∞ for each child of node do value : = max(value, minimax(child, depth − 1, false)) return value else (* minimizing player *) value : = +∞ for each child of node do value : = min(value, minimax(child, depth − 1, true)) return value (* initial call *) minimax(origin, depth, true)