Generalized implementation of alpha-beta search