From Requirements to Source Code: Evolution of Behavioral Programs

Research output: Contribution to journalArticlepeer-review


Automatically generating executable code has a long history of arguably modest success, mostly limited to the generation of small programs of up to 200 lines of code, and genetic improvement of existing code. We present the use of genetic programming (GP) in conjunction with context-oriented behavioral programming (COBP), the latter being a programming paradigm with unique characteristics that facilitate automatic coding. COBP models a program as a set of behavioral threads (b-threads), each aligned to a single behavior or requirement of the system. To evolve behavioral programs we design viable and effective genetic operators, a genetic representation, and evaluation methods. The simplicity of the COBP paradigm, its straightforward syntax, the ability to use verification and formal-method techniques to validate program correctness, and a program comprising small independent chunks all allow us to effectively generate behavioral programs using GP. To demonstrate our approach we evolve complete programs from scratch of a highly competent O player for the game of tic-tac-toe. The evolved programs are well structured, consisting of multiple, explainable modules that specify the different behavioral aspects of the program and are similar to our handcrafted program. To validate the correctness of our individuals, we utilize the mathematical characteristics of COBP to analyze program behavior under all possible execution paths. Our analysis of an evolved program proved that it plays as expected more than 99% of the times.

Original languageAmerican English
Article number1587
JournalApplied Sciences (Switzerland)
Issue number3
StatePublished - 1 Feb 2022


  • Behavioral programming
  • Code generation
  • Genetic programming

All Science Journal Classification (ASJC) codes

  • General Engineering
  • Instrumentation
  • Fluid Flow and Transfer Processes
  • Process Chemistry and Technology
  • General Materials Science
  • Computer Science Applications


Dive into the research topics of 'From Requirements to Source Code: Evolution of Behavioral Programs'. Together they form a unique fingerprint.

Cite this