SubRogue: the build so far

What is SubRogue? ⚔

It is a Roguelike game that connects to a blockchain. The game is only a proof-of-concept that shows the path forwards for creating more complex blockchain games. The end goal being an MMORPG on the blockchain.

Design Goals 🎮

Just a quick reminder of what I’m aiming for. Here are the design goals:

  • Rogue-like game that connects to a Substrate blockchain.
  • Uses on-chain randomness for procedural generation of maps and spawning of items / enemies.
  • Simple mechanics, but complex enough to be an entertaining challenge.

The build: steps to replicate🔨

At a high level, here are the two main things that I did:

  1. I followed a tutorial to build a Rogulike in Python.
  2. I integrated the Polkascan’s Python Substrate interface and SCALE codec.

Python Roguelike 💻

One of the best well known Python tutorials is hosted on Rogue Basin. That tutorial works for Python 2, but the author hasn’t updated it. Fortunately someone from the Roguelike dev community has created a version for Pythong 3.5+:

Python Roguelike Tutorial Revised

In the short amount of time that I spent on development I completed the first eight steps (0 to 7) out of 13:

This is a screenshot after Step 3. No combat here: only dungeon generation and movement.
This is a screenshot after Step 3. No combat here yet, but now have the field-of-view.

Extra functions

While the tutorial is a great start to building a simple and playable game, it was not designed to be a blockchain game so there are a few things that need to be coded afresh.

def hasher_range(range_min, range_max, seed):
# want to get a pseudo-random number in some range(min, max)
hash_the_seed = hasher(seed) # blake2b hash to integer

modulus = range_max - range_min + 1
fn_output_pre = hash_the_seed % modulus
fn_output = fn_output_pre + range_min
return fn_output
Left: the purple spot is the trigger tile. Right: How the dungeon looked after further generation and exploration.

Connecting to Substrate chains ⛓

There are two Python libraries that you need to import in order to get data from a Substrate chain. Both libraries are written and maintained by the Polkascan team:

  1. Substrate interface; and
  2. The SCALE codec.
substrate = SubstrateInterface(

Left: code for getting latest Kusama block hash. Right: the first room show 2 orcs and the yellow field-of-view.

Acknowledgements 🏅

I’d like to give thanks to the following people from feedback on my previous blog or for engaging in discussion about building SubRogue.

About me🎯

Currently, I work at the Web3 Foundation (mainly running the grants program). This blog is of a personal nature. It just so happens that my hobby aligns with work.

Questions / Comments?❓

You can create a reply to me here on Medium, or reach out to me on Twitter: @EAThomson.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store