implementation of negmax.java