Programmable stochastic self-assembly of modular robots provides promising means to formation of structures at different scales. Formalisms based on graph grammars and rule-based approaches have been previously published for controlling the self-assembly process. While several rule-synthesis algorithms have been proposed, formal synthesis of rulesets has only been shown for self-assembly of abstract graphs. Rules deployed on robotic modules are typically tuned starting from their abstract graph counterparts or designed manually. In this work, we extend the graph grammar formalism and propose a new encoding of the internal states of the robots. This allows formulating formal methods capable of automatically deriving the rules based on the morphology of the robots, in particular the number of connectors. The derived rules are directly applicable to robotic modules with no further tuning. In addition, our method allows for a reduced complexity in the rulesets. In order to illustrate the application of our method, we extend two synthesis algorithms from the literature, namely Singleton and Linchpin, to synthesize rules applicable to our floating robots. A microscopic simulation framework is developed to study the performance and transient behavior of the two algorithms. Finally, employing the generated rulesets, we conduct experiments with our robotic platform to demonstrate several assemblies.