A genetic algorithm for the Zen Puzzle Garden game


In this paper we present a novel genetic algorithm (GA) solution to a simple yet challenging commercial puzzle game known as Zen Puzzle Garden (ZPG). We describe the game in detail, before presenting a suitable encoding scheme and fitness function for candidate solutions. By constructing a simulator for the game, we compare the performance of the GA with that of the A* algorithm. We show that the GA is competitive with informed search in terms of solution quality, and significantly out-performs it in terms of computational resource requirements. By highlighting relevant features of the game we hope to stimulate further work on its study, and we conclude by presenting several possible areas for future research.

This is a preview of subscription content, log in to check access.

Fig. 1
Fig. 2
Fig. 3
Fig. 4


  1. Berger MS, Lawton JH (2007) Multi-agent planning in Sokoban. Multi-agent systems and applications V. Lecture notes in computer science, vol 4696. Springer, pp 334–336

  2. Botea A, Müller M, Schaeffer J (2003) Using abstraction for planning in Sokoban. In Schaeffer J, Müller M, Björnsson Y (eds) Computers and Games 2002, number 2883 in Lecture notes in computer science. Springer Verlag, pp 360–375

  3. Dechter R, Pearl J (1985) Generalized best-first strategies and the optimality of A*. J ACM 32(3):505–536

    MathSciNet  MATH  Article  Google Scholar 

  4. Demaine ED, Hoffmann M (2001) Pushing blocks is NP-complete for noncrossing solution paths. Proceedings of the 13th Canadian Conference on Computational Geometry (CCCG 2001), Waterloo, Ontario, Canada, 13–15 August 2001, pp 65–68

  5. Dor D, Zwick U (1999) SOKOBAN and other motion planning problems. Comput Geom Theory Appl 13(4):215–228

    MathSciNet  MATH  Article  Google Scholar 

  6. Goldberg DE (1989a) Genetic algorithms in search, optimization, and machine learning. Addison-Wesley, Boston

    Google Scholar 

  7. Goldberg DE (1989b) Zen and the art of genetic algorithms. Proceedings of the 3rd international conference on genetic algorithms, pp 80–85

  8. Hart PE, Nilsson NJ, Raphael B (1968) A formal basis for the heuristic determination of minimum cost paths. IEEE Trans Syst Sci Cybern 4(2):100–107

    Article  Google Scholar 

  9. Hong T-P, Huang J-Y, Lin W-Y (2002) Applying genetic algorithms to game search trees. Soft Comput 6(3–4):277–283

    MATH  Article  Google Scholar 

  10. Houston R, White J, Amos M (2011) Zen puzzle garden is NP-complete (submitted)

  11. Junghanns A, Schaeffer J (2001a) Sokoban: enhancing general single-agent search methods using domain knowledge. Artif Intell 129(1–2):219–251

    MathSciNet  MATH  Article  Google Scholar 

  12. Junghanns A, Schaeffer J (2001b) Sokoban: improving the search with relevance cuts. Theor Comput Sci 252(1–2):151–175

    MathSciNet  MATH  Article  Google Scholar 

  13. Kendall, G, Spoerer, K (2004) Scripting the game of Lemmings with a genetic algorithm. Proceedings of the 2004 Congress on Evolutionary Computation (CEC2004), June 19–23, Portland, Oregon, USA, IEEE Press, pp 117–124

  14. Kendall G, Parkes A, Spoerer K (2008) A survey of NP-complete puzzles. ICGA J 31(1):13–34

    Google Scholar 

  15. Korf RE (1997) Finding optimal solutions to Rubik’s Cube using pattern databases. Proceedings of the AAAI Conference on Artificial Intelligence, Providence, RI, USA, Wiley, pp. 700–705

  16. Lexaloffle Games. Zen Puzzle Garden. Trial version downloadable at http://www.lexaloffle.com/zen.htm

  17. Mantere T, Koljonen J (2007) Solving, rating and generating Sodoku puzzles with GA. Proceedings IEEE Congress on Evolutionary Computation (CEC) September 25–28, 2007, Singapore, IEEE Press, pp 1382–1389

  18. Meffert K, Rotstan N, Knowles C, Sangiorgi U JGAP: Java genetic algorithms and genetic programming package. http://jgap.sf.net

  19. Osborne MJ, Rubinstein A (1999) A course in game theory. MIT Press, Cambridge

    Google Scholar 

  20. Pirsig RM (1976) Zen and the art of motorcycle maintenance. Corgi, London

    Google Scholar 

Download references


The authors thank Joseph White (author of ZPG) for invaluable assistance with the game, David Corne for useful advice on representation schemes, and David Goldberg (1989b) and Robert M. Pirsig (1976) for titular inspiration.

Author information



Corresponding author

Correspondence to Martyn Amos.

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Amos, M., Coldridge, J. A genetic algorithm for the Zen Puzzle Garden game. Nat Comput 11, 353–359 (2012). https://doi.org/10.1007/s11047-011-9284-7

Download citation


  • Genetic algorithm
  • Transport puzzle
  • NP-complete
  • Game A*