I implemented this in java when I first learned about minimax in an AI class, so this all looks very familiar to me.
My scoring function must have been weak though. I remember being frustrated that I could still beat the algorithm. It was completely blind to traps that didn't matter in the near term, but that decided the game later when the board was filling up.