Modified the minimax function (still not done yet, still bugged)