Procedural generation using Quantum

Procedural generation is an interdisciplinary field which makes use of a variety of computational methods to generate content. It describes any situation where content is generated procedurally by an algorithm. Application areas of procedural generation include in games such as to generate crossword puzzles, maps, character story lines in order to give a dynamic nature of a game.

Too lazy to design game levels? Use procedural generation.

We will be dealing with application of procedural generation in generating dynamic maps. Procedural generation has been achieved by classical computers but how can it be achieved using quantum? This article explains how.

Before we dive deep into the concept of procedural generation and how we achieved it using quantum, let me give a little background context. This project was a collaborative one day hackathon, which was done during the first ever Qiskit Camp Africa.

Qiskit Camps are an immersive experience that consists of training sessions, deep technical talks, and a hackathon alongside the Qiskit core development team.

Quantum computing is an emerging technology that promises quite alot of advantages in a wide range of computational problems. Before the Qiskit camp I had close to zero experience with Quantum programming with qiskit , but came out with a new skill and enthusiasm about what quantum computing has to offer.

What is a quantum computer and how does it differ to the classical “normal” computer? The difference is in how they store and process information. A classical computer operates in bits, which have two states 0 or 1, ON or OFF, TRUE or FALSE. While a quantum computer operates in qubits which can be 0, 1 or BOTH. Yeah you heard me right BOTH!!

Superposition for dummies
Qubit be like

Physicist call this phenomena super-position, which is the state of being in more than one state at once. Quantum computers therefore have the potential to offer way better solutions than classical ones because having more states means more shorter solutions per unit time.

What is Qiskit?

Qiskit is an open-source quantum computing software development framework for leveraging today’s quantum processors in research, education, and business.

IBM Q’s qiskit gives us the opportunity to access a quantum computer remotely to explore and experiment on what quantum has to offer. And it is all in python, hence quite easy to learn.

Resources for learning how to program with qiskit:

Procedural map generation hackathon project walk through

All code on how we achieved this can be found on my github here. Procedural generation is achieved by deterministically creating a random seed. A quantum bit having the superposition property played the role of generating random values together with a random seed to create the maps gradient. I will summarize the code with two major steps that were used to achieve this:

  • Step 1: Circuit Generation - Here we came up with a quantum circuit that generates random values to map on the generated map whose main purpose was to use the random counts generated as a gradient of the map landscape. We used a 2 qubit quantum circuit, therefore we expected 4 output counts of bit values: 00, 01, 10, 11.
Circuit image
  • Step 2: Map Generation - At this stage we created methods for map generation that utilises the random gradient values, this was achieved through adding pixel values to the map determining what to plot as land and what as ground and achieving realism. Realism was achieved by the perlin noise algorithm that creates realism in computer generated content. Perlin noise is an algorithm used to create realism in computer generated content hence creating naturally appearing textures.

Again, all the code is here, feel free to play with it.

Further reading

For comprehensive detail on procedural generation check out James Wooton’s awesome work on procedural generation in generating terrain islands and other cool stuff: here

Solving real world problems through technology