Skip to content

Instantly share code, notes, and snippets.

@Karn
Karn / states.py
Created July 29, 2017 07:19
Python State Machine - States
class State(object):
"""
We define a state object which provides some utility functions for the
individual states within the state machine.
"""
def __init__(self):
print 'Processing current state:', str(self)
def on_event(self, event):
@Karn
Karn / simple_device.py
Created July 29, 2017 07:18
Python State Machine - Simple State Machine
from states import LockedState
class SimpleDevice(object):
"""
A simple state machine that mimics the functionality of a device from a
high level.
"""
def __init__(self):
""" Initialize the components. """
@Karn
Karn / example.sh
Last active July 29, 2017 07:19
Python State Machine - Example Output
$ python
Python 2.7.13 (default, Apr 4 2017, 08:47:57)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from simple_device import SimpleDevice
>>> device = SimpleDevice()
Processing current state: LockedState
>>> device.on_event('device_locked')
>>> device.on_event('pin_entered')
Processing current state: UnlockedState
@Karn
Karn / bastion-of-the-void.md
Created April 18, 2017 02:22
Possible raid adaptation of the Pest Control Minigame

Bastion of the Void

Introduction
  • Mid-tier raid based on pest control.
  • Takes place on various floating platforms in the void.
  • Randomly spawns 4 boss platforms.
Story