<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Justin Duewel-Zahniser on Medium]]></title>
        <description><![CDATA[Stories by Justin Duewel-Zahniser on Medium]]></description>
        <link>https://medium.com/@justindz?source=rss-e859d4cbc99d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tvv7r_zkBDduoyY2axGNrQ.jpeg</url>
            <title>Stories by Justin Duewel-Zahniser on Medium</title>
            <link>https://medium.com/@justindz?source=rss-e859d4cbc99d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:31:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@justindz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python Lambda Early-Binding for a Game AI Planner]]></title>
            <link>https://justindz.medium.com/python-lambda-early-binding-for-a-game-ai-planner-89db7e45eb4a?source=rss-e859d4cbc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/89db7e45eb4a</guid>
            <category><![CDATA[rpg]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[closure]]></category>
            <dc:creator><![CDATA[Justin Duewel-Zahniser]]></dc:creator>
            <pubDate>Tue, 13 Jul 2021 21:18:11 GMT</pubDate>
            <atom:updated>2021-07-13T21:18:11.848Z</atom:updated>
            <content:encoded><![CDATA[<p>This story is targeted at two audiences, which may or may not overlap:</p><ul><li>Readers interested in a detailed explanation of a score-based planner pattern, specifically in the context of a turn-based RPG combat system.</li><li>Readers struggling with Python’s late-binding in lambdas who, like me, found all the generic “i: x * i” examples conceptually helpful, but hard to adapt to their specific code.</li></ul><h3>The Planner</h3><p>When players in the game venture into a new room in the mine, they are confronted with a group of enemies they must fight and defeat to proceed further. Each participant in the fight takes one action per turn, in initiative order, until either the enemies or the party are defeated. Simple enough. The tricky part is getting the enemies to make good decisions!</p><p>The solution I had devised for a previous game (also turn-based, but a tactical RPG), works roughly like so:</p><ul><li>When an enemy is instructed to take_a_turn(), they make a plan to take every action available to them on every valid target (e.g. attack player, heal self, heal ally) in the fight.</li><li>Each plan consists of an action (function) and a score (int).</li><li>Enemies have goals with numeric values that influence the score of the plans they make. For example, one enemy may only have the goal of hurting players and so will never use a healing ability. Another enemy may have both goals, but favor hurting players more than healing.</li><li>When plans are made, scores are weighted by various things. For example, an enemy may favor hurting players more than healing allies based on its goals, but if an ally’s health is critically low, the relative value of healing that ally may be high enough that the plan is favored temporarily above smacking players.</li><li>When any viable plan is discovered, the function (e.g. the attack or heal spell) and its arguments (the enemy using it, the target, the state of the fight) are assigned to the plan’s action variable to be invoked later, if the plan is selected.</li><li>Once the enemy has made every viable plan, they are sorted by score and the highest score plan is chosen. This is the “best” thing the enemy could do that turn based on their abilities, goals, and the current state of the fight. The chosen plan’s action variable is then executed, causing the enemy to do the thing.</li></ul><p>What makes a system like this cool is that you can adjust enemy behavior in a variety of ways:</p><ul><li>Give the enemy more abilities.</li><li>Give the enemy more goals.</li><li>Change the enemy’s goal values.</li><li>Change the score weights for different plan types.</li></ul><p>None of these adjustments require code changes. Additionally, since all the enemies make context-based decisions, they can be combined with each other and should have interesting and reasonably intelligent interactions with each other and the players, again, with no added code or configuration. Of course, the tuning of the goal and scoring values to arrive at the desired behavior is a whole discipline on its own.</p><p><em>Note: if you are familiar with game programming, and game AI in particular, this is loosely based on Goal-Oriented Action Programming (GOAP). But, knowing me, probably butchered and poorly optimized.</em></p><h3>The Code</h3><p><strong>Enemy, with all their attendant decision-making logic:</strong></p><pre>class GoalType(Enum):<br>    damage_player = 1<br>    debuff_player = 2 #not used in this example<br>    heal_ally = 3<br>    buff_ally = 4 # not used in this example<br>    summon = 5 # not used in this example<br></pre><pre>class Goal:<br>    def __init__(self, goal_type: GoalType, value: int):<br>        self.goal_type = goal_type<br>        self.value = value</pre><pre>    # this method looks like overkill, but several future goals have multiple contributor types<br>    @staticmethod<br>    def get_contributor_effects_by_goal_type(goal_type: GoalType):<br>        if goal_type == GoalType.damage_player:<br>            contribs = [EffectType.damage_health]<br>        elif goal_type == GoalType.heal_ally:<br>            contribs = [EffectType.restore_health]<br>        else:<br>            raise Exception(f&#39;GoalType {goal_type} has no configured contributing effects&#39;)</pre><pre>        return contribs<br></pre><pre>class Plan:<br>    def __init__(self):<br>        self.action = None<br>        self.debug = &#39;&#39;<br>        self.score = 0<br></pre><pre>class Enemy:<br>        # I omitted all the enemy member variables here not related to the problem, for brevity.<br>        # AI<br>        self.actions = actions<br>        self.goals = goals</pre><pre>    def take_a_turn(self, fight):<br>        plans = self.get_action_plans(fight)</pre><pre>        if len(plans) &gt; 0:<br>            print(f&#39;{self.name}\&#39;s plans:&#39;)<br>            for plan in plans:<br>                print(&#39;: &#39; + plan.debug)</pre><pre>            plans.sort(key=lambda x: x.score, reverse=True)<br>            the_plan = plans[0]<br>            print(f&#39;The chosen plan is: --{the_plan.debug}-- w/ score {the_plan.score}&#39;)<br>            return the_plan.action()<br>        else:<br>            return f&#39;{self.name} took no action.&#39;</pre><pre>    def get_action_plans(self, fight):<br>        plans = self.get_kill_player_action_plans(fight)</pre><pre>        if len(plans) &gt; 0:<br>            return plans</pre><pre>        # damage_player goal<br>        goal = [x for x in self.goals if x.goal_type == GoalType.damage_player]</pre><pre>        if len(goal) &gt; 0:<br>            plans += self.get_damage_player_plans(goal[0], fight)</pre><pre>        # heal_ally goal<br>        goal = [x for x in self.goals if x.goal_type == GoalType.heal_ally]</pre><pre>        if len(goal) &gt; 0:<br>            plans += self.get_heal_ally_plans(goal[0], fight)</pre><pre>        return plans</pre><pre>    def get_damage_player_plans(self, goal, fight):<br>        plans = []</pre><pre>        for action in self.actions:<br>            if action.targets_players and action.is_usable(fight.states):<br>                effects = list(filter(lambda effect: effect.type == EffectType.damage_health, action.effects))</pre><pre>                if len(effects) &gt; 0:<br>                    for character in fight.characters:<br>                        dmg = character.estimate_damage_from_enemy_action(self, action)<br>                        plan = Plan()<br>                        plan.score = goal.value + int(100.0 * dmg / character.health)<br>                        plan.action = lambda: action.do(user=self, target=character, fight=fight)<br>                        plan.debug = f&#39;damage {character.name} w/ {action.name} score {plan.score}&#39;<br>                        plans.append(plan)</pre><pre>        return plans</pre><pre>    def get_heal_ally_plans(self, goal, fight):<br>        plans = []</pre><pre>        for action in self.actions:<br>            if action.targets_allies and action.is_usable(fight.states):<br>                effects = list(filter(lambda effect: effect.type == EffectType.restore_health, action.effects))</pre><pre>                if len(effects) &gt; 0:<br>                    for enemy in fight.enemies:<br>                        plan = Plan()<br>                        plan.score = goal.value + 100 - int(enemy.current_health / enemy.health * 100)<br>                        plan.action = lambda: action.do(user=self, target=enemy, fight=fight)<br>                        plan.debug = f&#39;heal {enemy.name} w/ {action.name} score {plan.score}&#39;<br>                        plans.append(plan)</pre><pre>        return plans</pre><p><strong>The Enemy used for testing — ignore all the numbers, which are just various stats</strong></p><pre>enemies = {<br>    &#39;slime&#39;: Enemy(&#39;Slime&#39;, 1, 0.3, 1, 0.3, 1, 0.3, 1, 0.3, 10, 0.1, 5, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,<br>                   [SingleTargetAttack(&#39;Headbutt&#39;, &#39;&#39;, 0, 0.05,<br>                                       [SpellEffect(EffectType.damage_health, Elements.earth, 1, 4)]),<br>                    SingleTargetHeal(&#39;Regenerate&#39;, &#39;&#39;, 3,<br>                                     [SpellEffect(EffectType.restore_health, Elements.water, 2, 5)])],<br>                   [Goal(GoalType.damage_player, 500), Goal(GoalType.heal_ally, 450)]),<br>}</pre><p><strong>How an ability and its do() function is defined</strong></p><pre>class SingleTargetHeal(Action):<br>    def __init__(self, name: str, description: str, cooldown: int, effects: [SpellEffect]):<br>        for effect in effects:<br>            if effect.type != EffectType.restore_health:<br>                raise Exception(f&#39;SingleTargetHeal {name} has an unsupported effect type {effect.type}&#39;)</pre><pre>        super().__init__()<br>        self.name = name<br>        self.description = description<br>        self.cooldown = cooldown<br>        self.effects = effects<br>        self.targets_players = False<br>        self.targets_allies = True<br>        self.area = 0<br>        self.area_modifiable = False</pre><pre>    def do(self, user, target, fight):<br>        out = f&#39;{user.name} used {self.name} on {target.name}.&#39;<br>        targets = [target]</pre><pre>        if self.area &gt; 0:<br>            i = self.area</pre><pre>            while i &gt; 0:<br>                if fight.enemies.index(target) + i &lt;= len(fight.enemies) - 1:<br>                    targets.append(fight.enemies.index(target) + i)</pre><pre>                if fight.enemies.index(target) - i &gt; 0:<br>                    targets.insert(0, fight.enemies.index(target) - i)</pre><pre>                i -= 1</pre><pre>        for target in targets:<br>            for effect in self.effects:<br>                heal = target.restore_health(random.randint(effect.min, effect.max), user)<br>                out += f&#39;\n{target.name} regained {heal} health.&#39;</pre><pre>        return out</pre><h3>The Problem</h3><p>Due to my inability to figure out the correct syntax to early-bind the action and its parameters for later invocation when the highest scoring plan is selected, the enemies would correctly build the plans, correctly select the best plan, and then execute the wrong (in fact, last planned) action on the correctly planned target. In this case, the Slime would decide the best thing to do is to whack the player and then… heal the player instead.</p><p><strong>The debug statements from the planner</strong></p><pre>Slime&#39;s plans:<br>: damage Player w/ Headbutt score 502<br>: heal Slime w/ Regenerate score 450<br>The chosen plan is: --damage justindz#4247 w/ Headbutt score 502-- w/ score 502</pre><p><strong>What actually happened</strong></p><pre>Pico Slime goes next.<br>Pico Slime used Regenerate on you.<br>You regained 3 health.</pre><h3>The Solution</h3><p>Thanks to Stack Overflow user Carcigenicate (<a href="https://stackoverflow.com/users/3000206/carcigenicate">https://stackoverflow.com/users/3000206/carcigenicate</a>) for leading me to the solution. While I had correctly diagnosed the problem as a late-binding issue with Python lambdas, and had attempted to resolve it by “freezing” the variables at definition time using default parameters, I had not “frozen” the one element most important: the “action” function object itself.</p><p>The working code follows. Note that action is passed to the lambda as a default parameter — that’s the key. Also note that because the fight parameter has the same state throughout the entire planning process, that can be passed used without worrying about binding. The same is true for the user (self)… saving entire characters of code (yipee!). The action and the target must early-bind for the pattern to work.</p><p>Instead of doing:</p><pre>plan.action = lambda: action.do(user=self, target=enemy, fight=fight)</pre><p>We do:</p><pre>plan.action = lambda action=action, enemy=enemy: action.do(self, enemy, fight)</pre><h3>The Project</h3><p>In case you are curious about the game itself — not really the subject of this story — I will give a brief explanation. I intend at some point to write a follow-up story about adapting the game concept to Discord as a medium.</p><p>The game is a text-based RPG roughly in the loot grinder genre. It features a series of infinitely deep mines full of enemies that you can fight through, room by room, for increasingly higher risks and rewards. Being text-based, and room-based, it has some similarity to MUDs (yes, I am old). However, the character and gear progression is more influenced by games like Diablo and Path of Exile.</p><p>The game platform is a Discord bot running in my personal server. The bot is written in Python using discord.py with persistence via MongoDB Atlas. The uniquely interesting part of this project is translating the game patterns into Discord concepts, such as DMs, channels, messages, and reactions. But, as I said, that is another whole story in and of itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89db7e45eb4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Tale of ARPG Manager (So Far)]]></title>
            <link>https://justindz.medium.com/the-tale-of-arpg-manager-so-far-36e826b0bf77?source=rss-e859d4cbc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/36e826b0bf77</guid>
            <category><![CDATA[indie-game-dev]]></category>
            <category><![CDATA[arpg]]></category>
            <category><![CDATA[startup-lessons]]></category>
            <category><![CDATA[unity3d]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Justin Duewel-Zahniser]]></dc:creator>
            <pubDate>Sun, 21 Jul 2019 19:59:16 GMT</pubDate>
            <atom:updated>2019-07-21T19:59:16.804Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating my first independent game while working, single-parenting, and dating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_x7TApQ31ZrRo2CpsFd5A.png" /><figcaption>The loading screen for ARPG Manager.</figcaption></figure><h3><strong>How the Project Started</strong></h3><p>I was closing in on my mid 30s, divorced, with two teenage boys that I took care of 9 months out of the year. I had been working in IT Product Management for almost a decade up to this point and found myself in a job that paid well, but mostly sent me home exhausted and upset. While most of my co-workers were capable, intelligent, delightful, earnest people, a few very important ones (including two of my eventual bosses) proved to be anything but.</p><p>The company eventually embarked on a massive, expensive project whose objectives I felt to be most likely non-achievable— specifically because I had previously worked somewhere that sold solutions to the very problem this project would create. Additionally, I believed the project would not create value for the company — rather, it seemed designed to create career value for the project sponsor. I stuck it out as long as I could, against the advice of my awesome, new-at-the-time girlfriend, in order to build savings that would allow me to detox for a while on a TBD personal project. While all my equity turned to toilet paper, I did have a good salary and I lived well below my means, and so this part of the plan worked well.</p><p>I have always been a gamer. It started with pen and paper RPGs, such as Dungeons &amp; Dragons, Shadowrun, Rifts, Vampire, and many more. Eventually, my friends and I got into Magic: the Gathering, as well as video games. I begged my parents for a Nintendo Entertainment System and “Mario” for Christmas. My family was not wealthy, and so this was a stretch as far as Christmas requests went. As I unwrapped what I knew to be the coveted NES, I couldn’t fathom what the odd, oval bulge in the wrapping paper would reveal. My father, always the jokester, had delivered.</p><figure><img alt="A can of Mario olives, medium pitted black." src="https://cdn-images-1.medium.com/max/368/1*Al4zcwzSDe-NdWC9MnKrPg.jpeg" /></figure><p>My favorite games growing up were always the RPGs. I even talked my grandmother into buying me a strategy guide to Final Fantasy, which I didn’t own. I read it front-to-back for at least half a year until I had enough money to buy the game. So, if I was going to take time off, keep busy, learn something new, and hopefully create something I would personally enjoy, I decided that my project would be to create an RPG computer game. After doing the math, I concluded that I had a 9 month window in which to pull this off before needing a new source of income.</p><h3>The Game</h3><p>Next, I had to decide what kind of game to make. I had long dreamed about creating a location-based RPG that would help foster community and player physical health[1] but it would have been insane to try to be noticed alongside Pokemon Go, which was exploding around this time. So I put that aside for the time being. The two influences that ultimately converged to push me down the path of ARPG Manager were <a href="https://www.pathofexile.com/game">Path of Exile</a> and <a href="https://www.falloutshelter.com/">Fallout Shelter</a>.</p><p>Path of Exile (POE) is probably my favorite game of the modern era. It is a 100% free loot grinder Action RPG (or, ARPG) supported entirely by ethical micro-transactions. It sits in a genre most recognizable as the land of the Diablo franchise, though few will disagree that Path of Exile is best-in-class. In the spirit of my love for POE, I very much wanted to create some kind of loot grinder. However, I was keenly aware that trying to create a full ARPG would be a suicide mission.</p><p>At the time, I had also recently stopped playing Fallout Shelter. While I initially enjoyed the game, the mechanics that forced me to play constantly and react at all times in a crisis-management mode were exhausting and off-putting. I wanted to play it casually around other games, like POE, which were the focus of any significant time I could spend gaming. However, I enjoyed the simulation-of-an-RPG feel, and especially the wasteland exploration inspired by Progress Quest.</p><p>Blending these two together, I came up with the idea of essentially removing the crisis management aspects of Fallout Shelter and using loot grinder mechanics to orient the game around the Progress Quest-esque exploration. In order to provide reasons to explore, the game would still need to allow you to expand your base of operations, a la Fallout Shelter. It just wouldn’t ever come under attack or burst into flames when you were trying to do anything else with your life. And, thus, the concept for ARPG Manager was born, wherein you are the invisible sim overlord hiring and directing a team of explorers through automated exploration. In short, a casual “Football Manager” of a sci-fi ARPG.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_XL7UB7XG63gTf6T_3ylEQ.png" /></figure><p>Once the core idea fell into place, I tapped several other influences to build out the world. In addition to bad space jokes and terrible pop culture references, ARPG Manager contains references to some other personal favorite games throughout history. This list includes, but is not limited to:</p><ul><li>Phantasy Star Online</li><li>Final Fantasy</li><li>Asheron’s Call</li></ul><p>I also made the decision to make the game entirely free, using a similar ethical micro-transaction approach to POE. Of all the decisions described thus far, this one has so far taken the hardest turn. I’ll talk about this more later, but rest assured the game is still 100% free. Like, actual free with no strings attached.</p><p><em>[1] I pitched this to friends and colleagues in the mid-to-late 2000s. At the time, however, phone GPS accuracy, bandwidth, and battery life were hard constraints. Pretty sure I have “the receipts.”</em></p><h3><strong>The Stack</strong></h3><p>From the start of the project, I was confident in my web development and general programming skills. I was even confident in my ability to create a lightweight multiplayer game, having previously created a <a href="https://github.com/justindz/rubymud">simple MUD</a> from whole cloth as a way to learn Ruby over a decade ago. What I expected to be the biggest hurdle was learning game client development.</p><p>On the basis of this skills inventory, I decided to create the POC for the game server using what amounts to a REST API for the active portions of the game, and threads to run the automated explorations. I had fond memories of working with Sinatra and ActiveRecord, but I wanted to use Python for this project, and so I landed on a Flask server backed by MongoDB. Thus began the lingering, persistent dread that I still feel to this very moment that the server will eventually hit a scale ceiling or inhibit some critical functionality and need to be completely re-built.</p><p>In order to tamp down the dread initially, I decided to create a proof of concept (POC). The scope of the POC would be character creation, hiring explorers, managing inventory and gear, and simple combat. The client would be a simple React SPA that played the game like a MUD with a forms-based GUI. For the middleware that publishes adventure updates to the client, I adopted the amazing <a href="https://pusher.com/">Pusher</a> platform. I had to be able to connect to the POC with a handful of player accounts simultaneously with different browser sessions and should be able to play the game as several pseudo-people in parallel without any noticeable speed or play boundary issues.</p><p>It worked. In fact, it worked well enough that I made my first mistake: I added too much functionality to the React client over a two week period. I should have set it aside immediately and started learning graphical game client development because, in the grand scheme of things, those two weeks were essentially thrown away. It’s all washed out now that I’ve been working on this project for several years. But, a mistake is a mistake, and you don’t learn from them if you don’t acknowledge them.</p><p>Following that mistake, I did a bit of research and landed on Unity as my game development platform of choice. The tl;dr here is that I was presented with many options, but most of them seemed either too small for what I wanted to do (e.g. GameMaker) or too big for amateurs (e.g. Unreal). If you use either of those platforms at a high level, you are probably aware of all the ways in which my conclusion was and still is flawed. But, I had to pick one, and I picked Unity. This was definitely not a mistake.</p><p>Let’s talk about some more things that were.</p><h3>It’s Dangerous to Go Alone</h3><p>I knew from the beginning of the project that it would require art and music. And I knew that I could produce neither of these things to the level of quality required. So from the moment I started working on the graphical client, I knew that I would eventually have to either scrap the project or contract out these elements.</p><p>However, I definitely thought that working 6 days a week, 12 hours per day on average for a 9 month period, even as a solo developer, would be more than enough to create and launch the game I envisioned.</p><p>I could not have been more wrong. I unequivocally bit off more than I could chew with the scope of the project, leaving me with two key problems:</p><ol><li>I exited my target time frame with a working, enjoyable game that was, nonetheless, not polished enough to release and scale[2].</li><li>I completely and utterly failed to account for the intense amount of marketing and promotion that would be required to <strong><em>even attract enough beta testers</em></strong>, let alone acquire enough players to sustain a business. Don’t get me wrong: I had a viable pessimistic financial model, which I ran by several smart and experienced people in the field and related fields. What I didn’t do the math on was how many human beings it would require to be actively doing both the building and managing, as well as the promoting.</li></ol><p>Here is the key takeaway from this mistake: <strong><em>what seems like the smallest, simplest game is a tremendous amount of work and probably insane to attempt without at least one partner</em></strong>.</p><p>With this experience under my belt and what I know now, I am much more gracious of bugs in other people’s games, and I never say “that’s it?” until I’ve at least seen the credits screen to know how any people and/or teams have been involved. Based on some of my experience consulting with game startups and participating closed and open betas as a tester myself, I was always understanding of the complexities of making a world of, say, Skyrim’s size behave. Now, I will probably stand up and applaud your minesweeper clone with the same fervor. Games are that crazy to make.</p><p><em>[2] At the end of this period, I started a new job to rebuild the old war chest. Development slowed way down for the following two years, while I commuted 3 hours to and from my new office. I’m talking, 95% slow down. The reason I’m back on it hard now is three-fold: I moved closer to work, adding ~2 hours per day back to my life, my oldest son finished high school, and my girlfriend and I moved in together. I have free time, and I have more energy to use it productively.</em></p><h3>A Big Boi</h3><p>Especially this one. While the sim overlord / automated exploration dichotomy created simple game play patterns, a few choices conspired to balloon the size of the game in ways I would not understand until I got underway.</p><p>First off, ARPG Manager is an online game. While it is certainly no MMORPG, there is a client and a server, there is a database, there is concurrency, and there are some small ways in which players can interact asynchronously. The hooks are in place to do races and ladders, as well. This required far more scaffolding that would be needed for a game with one player, simple persistence, and only a client. The jury is still out on whether or not I should have done it this way. However, I plan to continue working on this game as long as it makes even a small amount of sense, so I believe this will pay off in the long run.</p><p>Secondly, RPGs require a lot of content development. Had I made a platformer, even with light RPG elements, I could have skipped over creating and balancing the thousands of possible combinations of character, item, and monster stats present in the current, small iteration of ARPG Manager. If you are contemplating developing your first game, and especially if you are working alone, I strongly suggest not starting with an RPG. If you must, I suggest keeping it tiny and making it as procedural as possible. Another mistake that I made early on was attempting to hand-create all the game’s items. This proved too brittle — every time I changed some aspect of scaling, I had to adjust all the numbers again. Eventually, I wised up and started moving many of the scaling systems towards algorithms based on statistical models.</p><p>I did a few smart things along the way, though. I don’t want you to think I’m a complete idiot and only still alive through luck!</p><h3>Good Decisions</h3><p>One of the better decisions I made was to pivot away from the business model of selling ethical micro-transactions to a Patreon-based model. While I would one day love to be a full-time indie developer and live modestly on income from games, that is simply not where I’m at in life right now. And so, what I really want out of ARPG Manager is enough devoted fans to help offset the ongoing operational costs to keep the game running and growing. And, eventually, maybe enough supporters to be able to start a second game with a team where I am not needed in a lead development role. Patreon is a much better fit for me and what I want to do than retail pricing, subscription pricing, cosmetic sales, or Kickstarter.</p><p>Another great decision, which I credit to my product management experience, was baking qualitative and quantitative analysis into the closed beta process aimed validating my assumptions about the state of the game and player experience. The heartwarming part of this process was that the participants enjoyed the game and played more than I expected, on average. I also came away with data-driven insights into what aspects of the game were most and least engaging. If you’re interested in learning what aspect was the least engaging, as well as what I did with that information, check out the Patreon link below and read the July 19, 2019 post. As a bonus, that post contains markov chain-generated (and lightly hand-edited) patch notes for the final closed beta release, which is a tradition I straight up stole from POE.</p><p>Another good decision, which I mentioned previously, was adopting a SaaS-based middleware, in the form of Pusher. This one doesn’t require much explanation, however, as it simply saved me a healthy chunk of precious development time. I will disclose that they sent me a t-shirt and some stickers, but that was long before this plug.</p><p>And last, but not least, I found these amazing people to contract out the pieces I couldn’t do myself:</p><ul><li>Artists: <a href="https://twitter.com/JamoGames">Jamo Games</a>, <a href="https://twitter.com/Peanut_Sloth">Ector</a></li><li>Musician: <a href="https://twitter.com/NewSpruke">Spruke</a></li><li>Social Media: <a href="https://twitter.com/Revisedangel">Heather</a></li></ul><p>I love the art, I love the music, and I will hopefully be able in the future to need and afford Heather’s services again as well. They were worth every penny.</p><h3>Current Status and Next Steps</h3><p>As a final note, there are only three tasks remaining on my task board before cutting an open beta candidate:</p><ol><li>Write up this ^ Medium post. Yes, this is semi-promotional. Gotcha.</li><li>Push to production and smoke test.</li><li>Host and start promoting the download link for the PC client[3].</li></ol><p><em>[3] The game also works great on Android. However, sideloading the .apk was really only manageable for the 25 closed beta testers. I need to go through the Google Play Store process to get beta distribution rights, which will take a bit longer.</em></p><h3><strong>Where to Go if You’re Interested in the Game</strong></h3><p>If you would like to try out the game during the open beta period — and first off, that warms my heart — your best bet is to keep an eye on one or more of the following resources. Once access is available, they will all be updated accordingly. I have a business trip over the next two days, and so I’m likely to flip the switch mid-week so I can be available for emergency tech support, bug fixes, and some amount of community management.</p><p>If you want more information about the game, check out the official website and/or the Patreon page.</p><ul><li><a href="https://www.cranemountaingaming.com/">Crane Mountain Gaming</a></li><li><a href="https://patreon.com/cranemountaingaming">Crane Mountain Gaming is creating Video Games | Patreon</a></li></ul><p>I also have a Discord server set up, which has seen most of its activity during the original closed beta phase, but which will hopefully ramp up again during open beta. IMHO, it’s worth joining if only so you can use our sweet ARPG Manager emoji.</p><figure><img alt="The ranid enemy type (a whimsical, mutant tree frog in pixel art form) shooting out its tongue." src="https://cdn-images-1.medium.com/max/512/1*WHBFvJb4ACQ76L9kb2NWMA.png" /><figcaption>Herpaderp.</figcaption></figure><p><a href="https://discord.gg/aZH68e4">Join the ARPG Manager Discord Server!</a></p><p>And, last but not least, you can <a href="https://twitter.com/CraneMtGaming">follow Crane Mountain Gaming on Twitter</a>. If you have questions about the game, this article, or my journey so far, hit me up on any of these channels. You can also email me through the Contact form on the official website.</p><p>Peace.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36e826b0bf77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamically Constructing a Google Assistant Carousel]]></title>
            <link>https://justindz.medium.com/dynamically-constructing-a-google-assistant-carousel-f2023e1019c9?source=rss-e859d4cbc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2023e1019c9</guid>
            <category><![CDATA[actions-on-google]]></category>
            <category><![CDATA[dynamic-carousel]]></category>
            <category><![CDATA[google-assistant]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Duewel-Zahniser]]></dc:creator>
            <pubDate>Thu, 22 Nov 2018 14:51:58 GMT</pubDate>
            <atom:updated>2018-11-22T14:51:58.943Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: if you are purely here for guidance on the technical problem indicated in the title, jump down to “The Solution.”</em></p><p>By day, I work at a family-owned business that provides software and services to libraries. A while back, I got interested in creating a proof-of-concept integration between our software and a voice assistant. I’ve recently had the bandwidth to scratch that itch. I decided to start with Google Assistant, figuring that owning a Pixelbook and Pixel 2 phone would give me some advantages.</p><p>Although the juicier ambition is to assist patrons and students with checking due dates, renewing loans and other more transaction-based use cases, I started with something simple: search. Although the majority of our software is built on APIs, they are still private for lack of the management tools necessary to support developers, such as version control, deprecation, docs, and test consoles (something I’m working on fixing, but that’s a different post). Search, however, I could work with pretty easily. And, when learning a new framework and design space, experience has taught me not to be too ambitious from the start.</p><p>Here was the goal I started with:</p><ul><li>User asks to search the library catalog.</li><li>The assistant uses key phrases such as “by” or “about” to choose from the following intents: title, author, subject, or series.</li><li>The assistant performs the search and indicates the number of results. For now, the assistant is limited to one page of up to 10 results.</li><li>For voice-only interfaces, the user can indicate a result number to get more detail on the title record.</li><li>For screen interfaces, the result set will be rendered as a carousel, including covert art for each title, if available.</li></ul><h3>The Problem</h3><p>For this to work, I needed to dynamically construct a carousel using non-deterministic elements. However, all of the tutorials and code examples provided by Google show only carousels based on a fixed number of already-known elements. Even worse, after a significant amount of time searching Google, reading StackOverflow articles and digging through the API documentation, I could not find a working example. All the examples I found either used a deprecated API or were presumably speculative approaches that people had suggested in good faith, but clearly not tested themselves.</p><p>Here are the two general approaches (with several variants) that I tried along the way:</p><ul><li>Create an empty carousel, construct each item in a loop and then add each item to the carousel. <strong>You cannot create an empty carousel; it must be constructed with the set of items already prepared.</strong></li><li>Create a carousel with one item, then immediately remove that item and add additional items. <strong>You cannot remove items from a carousel once it has been created, even though you can add items.</strong></li></ul><p>In case you are unclear about the distinction between deterministic and non-deterministic item sets, consider these two use cases:</p><p>1 — Build a carousel for menu items at your restaurant</p><p>Presumably, at any given time your restaurant has a set menu. Since you know the menu in advance, you could simply build your carousel to reflect the current menu items. When the menu changed, you could update your carousel. While this would be easier to maintain if it were dynamic, it’s an acceptable solution.</p><p>Incidentally, in the Google tutorial, you build a carousel to let someone choose a favorite color. They are only given three options, and the same three options every time. Luckily, two of them were blue, so I didn’t feel left out!</p><p>2 — Build a carousel for the results of a keyword search</p><p>Since you have no idea in advance what the user will search for, you don’t know how many items will be displayed in the carousel, nor do you know any information about the items. Therefore, the carousel would have to be constructed anew in code each time a search is performed.</p><h3>The Solution</h3><p>Ultimately, what worked was to create an empty <em>items</em> object, construct each <em>item</em> as another object in a loop, add them to the <em>items</em> object and then finally build the carousel off of the <em>items</em> object.</p><p>Now, a more seasoned javascript developer might have figured this out faster. I suffered from two handicaps. First, I’ve been doing Python and C# for ages (<a href="https://www.cranemountaingaming.com/games">games</a>), so I’m extremely rusty at javascript, and it has changed substantially since last I did much with it. And second, I tried to follow the API documentation which referenced OptionItem and OptionInfo classes as the elements of a carousel.</p><p>So, I tried for a while to import those classes, build them with constructors and then stuff them in the carousel. As it turns out, they have no constructors — you cannot actually build them directly, but only provide generic javascript objects in the right format to get converted by the carousel constructor. Oi.</p><p>Here’s what I ended up with:</p><pre>function searchResultCarousel(results) {<br>  var items = {};</pre><pre>results.forEach((result, index) =&gt; {<br>    console.log(`Building item from result: ${result.title}`);</pre><pre>items[index] = {<br>      optionInfo: {<br>        key: (index + 1).toString(),<br>        synonyms: result.title,<br>      },<br>      title: result.title,<br>      url: ``,<br>      image: new Image({<br>        url: `<a href="http://ls2content3.tlcdelivers.com/tlccontent?customerid=9999&amp;appid=ls2pac&amp;requesttype=BOOKJACKET-SM&amp;Isbn=${result.standardNumbers[0].standardNumber}`">[REDACTED DUE TO TRADE SECRETS]`</a>,<br>        alt: `Cover art for: ${result.title} - ${result.year}`<br>      }),<br>    }<br>  })</pre><pre>return new Carousel({<br>    title: &#39;Search Results&#39;,<br>    items: items<br>  });<br>};</pre><p>where the <em>results</em> object is a JSON object returned from the search API.</p><p>And here’s what it looks like in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rfej8WkNiQleHaVhmC015A.png" /><figcaption>Simulated voice search for subject = Aldo Leopold, showing search result carousel with cover images.</figcaption></figure><p>If I could recommend one improvement to the Actions on Google API documentation, it would be this:</p><p><strong>Show examples of dynamically constructed lists and carousels. </strong>It is both not very intuitive and there are a lot of people trying to figure it out, based on the many dead-end forum posts I found.</p><p>Also, credit to <a href="https://twitter.com/lukaszbyjos/status/1065599716501667840">this chap</a> for having the solution, but also helping me fix a crucial problem with []s that should have been {}s. I had, by that point, actually figured out the right assembly approach to the carousel items, but his loop was a lot more elegant, so I learned from that too.</p><p>So, that’s it. If you are trying to accomplish the same goal and running into similar hurdles, I hope this write-up moves you closer to a working solution. If you have any questions or feedback, hit me up here, <a href="https://twitter.com/justin_dz">Twitter</a>, wherever.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2023e1019c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Surviving the Age of the Amoral Minority]]></title>
            <link>https://justindz.medium.com/surviving-the-age-of-the-amoral-minority-3013d54f9552?source=rss-e859d4cbc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3013d54f9552</guid>
            <category><![CDATA[politics]]></category>
            <category><![CDATA[2016-election]]></category>
            <dc:creator><![CDATA[Justin Duewel-Zahniser]]></dc:creator>
            <pubDate>Sat, 17 Dec 2016 23:58:00 GMT</pubDate>
            <atom:updated>2016-12-17T23:58:00.599Z</atom:updated>
            <content:encoded><![CDATA[<p>Donald Trump will be the next President of the United States of America. The electoral college will not stop him. Nor, in my opinion, should they. Brace yourself for eight years* of kleptocracy and corporate oligarchy that will be staunchly defended by a loud minority of Americans (with foreign assistance) who gave up their principles in exchange for a safe space where a pathological liar constantly reminds them (members of the party of personal responsibility) that they are amazing and everyone wrong with their lives is someone else’s fault.</p><p>Many of you who asked me to write this are grappling with the question: what do we do now? Let’s explore some options.</p><h4>If the Government No Longer Serves the People, Should the People Serve the Government?</h4><p>The Founders were deeply concerned about the prospect of the U.S. government turning corrupt and no longer serving the interests of the people. This is manifested in many ways: the system of checks and balances, the electoral college, the emoluments clause, the second amendment, and so on. I’ll quote Thomas Jefferson here:</p><blockquote>The British ministry have so long hired their gazetteers to <strong>repeat and model into every form lies about our being in anarchy, that the world has at length believed them, the English nation has believed them, the ministers themselves have come to believe them, and what is more wonderful, we have believed them ourselves</strong>. Yet where does this anarchy exist? Where did it ever exist, except in the single instance of Massachusets? And can history produce an instance of a rebellion so honourably conducted? I say nothing of it’s motives. They were founded in ignorance, not wickedness. <strong>God forbid we should ever be 20. years without such a rebellion.</strong> <strong>The people can not be all, and always, well informed. The part which is wrong will be discontented in proportion to the importance of the facts they misconceive. If they remain quiet under such misconceptions it is a lethargy, the forerunner of death to the public liberty.</strong> We have had 13. states independant 11. years. There has been one rebellion. That comes to one rebellion in a century and a half for each state. What country ever existed a century and a half without a rebellion? <strong>And what country can preserve it’s liberties if their rulers are not warned from time to time that their people preserve the spirit of resistance?</strong> Let them take arms. <strong>The remedy is to set them right as to facts, pardon and pacify them.</strong> What signify a few lives lost in a century or two? The <strong>tree of liberty</strong> must be refreshed from time to time with the blood of patriots and tyrants.</blockquote><p>Should the new administration prove as kleptocratic and unrepresentative (or, worse, fascist) as we have every reason to believe it will be, and should it be re-elected in spite of such behavior, Thomas Jefferson would have been the first to consider it no longer legitimate. The founders wanted to create a system in service of liberty — that was the <strong>only </strong>thing about it they truly held sacred. And they did not believe it would or should last forever. I don’t think Thomas Jefferson or any of his colleagues planned for instantaneous, anonymous, global communication, for example. When the constitution was written, threats generally arrived by boat rather than by a push notification.</p><p>Now, the bad news is that the government has a monopoly on violence, legitimate or not. The second amendment gave us the right to keep and bear arms, such that a corrupt government could not disarm us and therefore remove our ability to resist. This protection was far more effective when everyone had rifles, and there were maybe a few cannon involved. If you think your AR-15 is going to stand up to the DOD, and you’re looking forward to it, then you’re just a suicide cultist.</p><p>The good news is that non-violent resistance is more effective anyway (see: <a href="http://www.forbes.com/sites/alexknapp/2014/07/24/the-proven-superiority-of-nonviolent-resistance/#25dd0fec1c27">http://www.forbes.com/sites/alexknapp/2014/07/24/the-proven-superiority-of-nonviolent-resistance/</a>). For more evidence, take a look at what Putin just did to our society and government without firing a single shot. We have the strongest military in the history of the world, right? Well, turns out that depends on the battlefield.</p><p>Unfortunately, I don’t have any bright ideas about what type of non-violent actions to take. Personally, I’ll be looking to join appropriate protests (I live near DC) and I’ll be boycotting products and services with any ties to administration officials (driving further to pump at a non-Exxon station, not watching the movies I’ve been meaning to watch, but which were funded by Steve Mnuchin, etc.). But I don’t believe that good faith members of either major party will rise up in any kind of grand, coordinated action until things are well and truly fucked. This is not a cynical belief, but a pragmatic belief. The level of alarm you feel, as an intelligent, informed person is simply <strong>not typical</strong>.</p><h4>It Can Still Work, But We’ll Need a New Coalition</h4><p>As someone who still believes in our system of government — or at least needs more evidence than one election to believe it is no longer up to the task of the Internet Age — I prefer the idea of building a new coalition. Not only could this win elections, but it would also demonstrate that cooperation and compromise are still more powerful than litmus tests and unprincipled partisanship. What this requires of us is to deeply examine which of our principles and positions are most important. You may, e.g., feel very strongly that more gun control is needed (I would argue that evidence doesn’t support this). But do you believe that is more important than restoring our democracy? I’m asking you not to weigh each of your positions against their opposite, but to weigh them against a situation in which none of your principles has <strong>any </strong>representation.</p><p>Okay, so what could that platform look like? I made a straw man, using some ideas I’ve bounced off of real conservatives in the wild over the last few years. More of a thought experiment than a policy proposal. This is not a complete platform, but gives some examples of evidence-based positions that I believe could be staked out in the center of both current major parties. Feel free to hit me up if you have any questions about the details or discussion behind this.</p><h4>Preamble</h4><p>Our political process has become so ideological and so identity-driven that voters and politicians increasingly put party before country and view compromise and cooperation as capitulation. This has eroded public trust in the government. This trust must be restored, as it is vital to safeguarding our democracy against any interest, foreign or domestic, public or private who seeks power at the expense of our freedom.</p><p>A key step we must take to restore cooperation in our political process is to reduce the size and power of the federal government and, therefore, to limit the benefits of controlling the government. Citizens must hold participants in the process to standards of good faith — something they are increasingly willing to selectively overlook, according to a cost-benefit analysis.</p><h4>Education</h4><ul><li>Increase salaries for public school teachers significantly — make public teaching a more competitive and financially rewarding career. Increase charter schools as well to ensure market-based alternatives to public education.</li><li>Return curriculum and testing standards to the states. Establish a federal advisory council of nationally-recognized education leaders and industry leaders, by educational subject, to create reference curriculum for use by the states informed by educational best practices and by the current and future needs and employment gaps of the private sector.</li><li>Promote skilled trade programs in schools as an alternative to academic tracks. Differentiate, for example, between someone who wants to learn computer science and someone who wants a programming career.</li></ul><h4>Economy</h4><ul><li>Reduce non-environmental regulations on companies to increase innovation and efficiency. Strengthen anti-trust as well as oversight and enforcement of remaining regulations to ensure open markets and the protection of the public.</li><li>Establish a living wage with a predictable review and adjustment cycle. Companies are not required to pay the living wage, but will be ineligible for taxpayer-funded benefits, such as subsidies or contracts, and may not lobby federal officials.</li></ul><h4>Security</h4><ul><li>Reduce spending by eliminating projects sponsored by Congress which were not requested by or prioritized by the Department of Defense.</li><li>Increase the % of existing defense spending that is allocated to cyber security and information warfare.</li><li>Climate policy will be based on professional and academic scientific consensus.</li></ul><h4>Political Reform</h4><ul><li>States can require an ID to vote, but must provide them to citizens living at or below poverty at no cost. This protects the integrity of elections while ensuring that citizens are not disenfranchised.</li><li>Term limits in the House and Senate, as well as restrictions on gerrymandering.</li><li>Candidates for the presidency and vice presidency will be required to release tax returns.</li><li>Congressional salary increases and decreases according to changes in median household income. Members will no longer determine their own compensation.</li><li>Significant reduction in executive authority.</li></ul><h4>Health and Safety</h4><ul><li>Control prescription drug costs in order to reduce healthcare premiums and reduce the cost of Medicare and Medicaid.</li><li>No individual mandate.</li><li>Allow the sale of insurance across state lines.</li><li>It will be unlawful to sell firearms to individuals on the No Fly list. Create an accessible, transparent and expeditious due process appeal for the No Fly list to ensure that it cannot be used as a tool to target citizen’s for other purposes. Regulations will not be placed on magazine capacity, brand or model. Shift spending on non-criminal gun regulation and enforcement to mental health.</li></ul><p>Something like that.</p><p>*<em>in my lifetime, there has been only one single-term presidency. If you want to know who will be president, ask yourself who most Americans would rather have a beer with. It wasn’t Hillary, it wasn’t Gore, it wasn’t Romney and it wasn’t George H.W. Bush when standing next to Bill Clinton. The current front-runners to head the Democratic party are not going to beat Trump at this — especially not in the post-truth era where the alt-right would happily run a personal smear campaign against Jesus, if they thought he was liberal (hint: he was). Plus, voting Trump out of office would be admitting defeat in a culture/holy war. The amoral minority would rather you suffer than they lose</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3013d54f9552" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>