Abstract. There are two main challenges in developing computational models of a real-world phenomena. One is the difficulty in ensuring clear communication between the scientists, who are the end-users of the model, and the model developers. This results from the difference in their backgrounds and terminologies. Another challenge for the developers is to ensure that the resultant software satisfies all the requirements accurately. Utilising a formal notation such as Z which is easy to learn, read, understand and remember can address these issues by (a) acting as a means to unambiguously communicate between scientists and simulation developers, and (b) providing a basis for systematically producing and maintaining simulation code that meets the specification. In this paper, we describe a translation scheme for producing code for the widely used agent-based simulation environment NetLogo from Z specifications. Additionally, we report on the use of the approach on a real project studying the movement of chyme, i.e. food undergoing digestion, through a pig's intestine as a means of understanding the effect of dietary fibre on human health.