The Python Game Book

code games. learn Python.

User Tools

Site Tools




Slow Goblins Tutorial

This is a python3 tutorial about two goblins doing role-playing game-combat. I explain everything in this tutorial very slow, since the title. This tutorial aims to:

  • show you that game programming with python3 is easy to learn and fun to do…
  • help you navigating and making use of the python3 online documentation…
  • introduce you to the basic commands and functions of pyhton3…
  • help you to better understand existing (combat) models of role playing games and enable you to invent your own models


This tutorial make use of the awesome technology of, enabling you to write, edit, run, debug and trace python code directly inside your browser. No installation or downloads necessary. All you need is a working internet connection.

However it is strongly recommended that if you can you are allowed you take those actions before starting:

  • download and install the latest python3 version for your computer from
  • use either python's idle3 shell and editor or download / install another python shell / python editor.

start the tutorial



what you don't learn

In this tutorial, there are no sound or graphics. Not even colored text. Look for other tutorials, like the pygame tutorial, instead if you can't life without colors. This tutorial is about simulating combat and number crunching mostly, as well as teaching you the necessary python skills to do so.

what you learn

  • combat simulation of computer role playing games
    • stats, attributes, rolls,
    • (theory: probability)
  • variables
  • for loop, while loop, boolean expression break
    • iterating over generator from range()
    • (iterating over list)
  • using online documentation of range()
  • using arguments (parameters)
  • if elif else conditionals
    • True, False, pass
    • theory: in <, >, ==, <=, >=
    • theory: or, and, not
  • import random module
    • random.randint(), usning online documentation
  • print()
    • .format() mini language, formatting numbers {:3d}
  • functions def, return, default arguments
    • locals scope of variables in functions, passing values as arguments to functions
  • class()
    • instances, attribute, methods, class attributes (class instances)
  • statistic
    • normal (gauss) distribution, variance, mean
en/secret/goblins/start.txt · Last modified: 2020/05/03 20:46 by horst