Using molecular dynamics simulation, we study dipolar glass in crystals composed of slightly spheroidal, polar particles and spherical, apolar impurities between metal walls. We present physical pictures of ferroelectric glass, which have been observed in relaxors, mixed crystals (such as KCN KBr ), and polymers. Our systems undergo a diffuse transition in a wide temperature range, where we visualize polar nanoregions (PNRs) surrounded by impurities. In our simulation, the impurities form clusters and their space distribution is heterogeneous. The polarization fluctuations are enhanced at relatively high T depending on the size of the dipole moment. They then form frozen PNRs as T is further lowered into the nonergodic regime. As a result, the dielectric permittivity exhibits the characteristic features of relaxor ferroelectrics. We also examine nonlinear response to cyclic applied electric field and nonergodic response to cyclic temperature changes (ZFC/FC), where the polarization and the strain change collectively and heterogeneously. We also study antiferroelectric glass arising from molecular shape asymmetry. We use an Ewald scheme of calculating the dipolar interaction in applied electric field.