An algorithm generating morphology of 2D and 3D stochastic Wang tiles is presented in thiscontribution. The algorithm is based on the discrete element method (DEM) and is therefore applicableprimarily for matrix-based microstructures with separate inclusions with emphasis on producingmaximally random dense packings. An open-source free DEM code YADE was used for all the computations.The method is illustrated with a 2D exemplary realization of Wang tiling and comparisonagainst Periodic Unit Cell representation in terms of spatial statistics is provided.