Cleaned up code, implemented minmax algorithm--have not checked correctness