starting minimax, but a bit of a mess.
another shot at minimax