finished with alpha-beta pruning, need to check that it works.