public int winner() {
        // A player captured enought seeds

        if (position[12] > 24)
            return SOUTH;

        if (position[13] > 24)
            return NORTH;
        
        if (position[12] == 24 && position[13] == 24)
            return DRAW;
        
        // The game hasn't ended yet
        
        if (hasLegalMoves())
            return DRAW;

        // No legal moves can be performed. Each player captures the
        // remaining seeds on their side
        
        byte south = position[12];
        
        for (int i = 0; i < 6; i++)
            south += position[i];

        byte north = position[13];
        
        for (int i = 6; i < 12; i++)
            north += position[i];
        
        if (south == north)
            return DRAW;
        
        return (south > north) ? SOUTH : NORTH;
    }