Author and project
We wanted to use IBM’s quantum computers to generate the levels for our game. They can be accessed with Qiskit, a python library. Accessing the library would’ve been trivial had we been using a python game engine/library such as pygame but we weren’t and as such had to explore other ways of connecting Python.
In the end we ended up creating a Python API which the game then made calls to. The following links should prove helpful when making and hosting the server.
This way also makes it easy for other projects to use the same code. I also made a personal project that uses the same server as Project Alpha for generation. It was trivial to start using it even though I was using a different game engine.
Flask is my go-to Python web framework. It’s easy to get started and because of it’s popularity it has a good number of tutorials online. It’s also fast to make APIs with.
This is the service I ended up using to host the Qiskit API. It’s a bit more complex than Deta, but it can support larger libraries like Qiskit. Heroku’s free tier was enough for our project but it’s not perfect as it makes the API sleep after not being used for a while. The server then takes some seconds to boot up when called on later. The link is a tutorial on how to deploy flask applications to Heroku.”
This is the easiest hosting service I’ve come across but sadly, it’s not compatible with Qiskit. Deta limits your project’s file size and Qiskit goes well over that limit. However, it’s still very convenient for times when your project is under 250mb. Deta is also free.
Making requests in Unity
Here’s how to make requests to your API in Unity. https://github.com/leopeltola/quantum-seed-generator Example server Here’s the quantum seed generator repository we used for Project Alpha. Feel free to reuse code or fork the repository.