[portland] Manga Code (CSN)

kirby urner kirby.urner at gmail.com
Sat Mar 14 06:19:32 CET 2009

So "manga code" is different from "pseudo-code" in that it actually
runs (given necessary infrastructure), in this case in Python.  It's
"mange" or "comic book" in the sense of being a caricature of a real
production snippet, not "dumbed down" so much as "reduced" (anyone for
"shrunk"?).  Or call it a "cave painting".

Some of you may recall a presentation where I kicked off this idea of
back office source code that'd help galvanize the coffee shop biz
around a new business model.  The business model is what's open source
and I discuss it in some detail, with variations, in this blog:

http://mybizmo.blogspot.com/search?q=writhe  (announcement of CSN as a project)
http://coffeeshopsnet.blogspot.com/2009/03/open-source.html  (specific
post about the source code below)

Not everything about this franchise need be open source.  Picture the
game DVDs (for the juke box) being delivered by armored car, directly
from skunkworks, just to be exaggerated about it (seriously though,
might be close source like HalfLife2 from Valve but much shorter
playing time).

Part of the draw is you find these cool games at a CSN affiliate
fairly exclusively sometimes, an incentive to visit (novelty is part
of the appeal).

Probably it's the whole idea of "manga code" that should be the
subject of comments, don't need to talk coffee shops a lot (this is
PPUG, not a CSN list).  I'd be happy to do another presentation
though, sometime later this year.

The basic idea: you steer bonus points to worthy causes of your
choosing as an optional part of the entertainment you get when buying
a drink or other menu item.  It's a little complicated, hence this
cartoon, which is also incomplete (note this is Python 3.x but it
takes 30 seconds to recast in 2.x).

Simulation: CSN
Vendor axis fixed:  Mars

Action:  customer selects good, nets bonus to
invest towards worthy cause, with skill level
rewarded (not pure chance), remainder to vendor.
House gets 20% profit (markup).  Vendor gets
demographic data (not shown).  Customer gets
kudos (not shown).  People who just play for
'Me!' all the time will come across as selfish.

from random import randint

house_gains = 0  # Fine Grind

thevendors = {'Mars':0,
              'Red Bull':0,
              'Jack Daniels':0} # technically a "salon"

thecauses = {'GreenPeace':0,
             'USG':0,  # help Uncle Sam sometimes?

# house games menu
thegames = {'Scary Clown':0,
            'Teddy Bear Tilt':0,
            'No Game':0}

class Packet:

    def __init__(self,
                 good = "Spearmint Gum",
                 bonus = 10):
        self.good = good
        self.bonus = bonus

class Sale:

    def __init__(self,
        self.packet = packet

    def select_game(self):
        for option,title in enumerate(thegames.keys()):
            print(option,' --- ',title)
        self.selection = list(thegames.keys())[int(input("""
            Whaddya wanna play genius?
            """ ))]

    def select_cause(self):
        for option,title in enumerate(thecauses.keys()):
            print(option,' --- ',title)
        self.worthy = list(thecauses.keys())[int(input("""
            What do you care about?
            """ ))]

class Game:

    def __init__(self,
        self.game  = thesale.selection
        self.cause = thesale.worthy
        self.bonus = thesale.packet.bonus

    def play(self):
        real game goes here (might be a hard one)
        print("Playing... ", self.game)
        the_house = .20
        the_cause = .01 * randint(21,80)
        vendor_profit = 1 - the_house - the_cause
        return [self.bonus * it for it in (the_house,

def purchase():
    global house_gains
    mybuy = Packet("Mars Bar",50)
    thesale = Sale(mybuy)
    thegame = Game(thesale)
    proceeds = thegame.play() # real game goes here
    house_gains = house_gains + proceeds[0]
    thecauses[thesale.worthy] += proceeds[1]
    thevendors['Mars'] += proceeds[2]

def tester(n):
    global house_gains
    for i in range(n):

if __name__ == "__main__":

More information about the Portland mailing list