negamax :: Int -> Player -> State -> Int
negamax d p s
        | winnerOf s == Just p = 100
        | winnerOf s == Just (nextPlayer p) = -100
        | d == 0 || (all isRight $ board s) = 0
        | otherwise = minimum $
            map (negate . negamax (d - 1) (nextPlayer p)) (nextStates s)
negamax :: Int -> Player -> State -> Int
negamax d p s
        | winnerOf s == Just p = 100
        | winnerOf s == Just (nextPlayer p) = -100
        | d == 0 || (all isRight $ board s) = 0
        | otherwise = minimum $
            map (negate . negamax (d - 1) (nextPlayer p)) (nextStates s)
negamax d p s
        | winnerOf s == Just p = 100
        | winnerOf s == Just (nextPlayer p) = -100
        | d == 0 || (all isRight $ board s) = 0
        | otherwise = minimum $
            map (negate . negamax (d - 1) (nextPlayer p)) (nextStates s)