Print Page

Monday, May 15, 2017

Elm One Day In

I've been interested in the Elm programming language for several months, reading and poking around some at code examples but with too many hobbies competing, only finally started really writing some yesterday.

I usually do a gaming related project to learn a new programming language or framework on my own time, because that is where I have software itches to scratch. This time I started with the simple die roll example and my first step was learning how to take a program where the model is a single Integer that gets updated to a record with two attributes, one the value rolled on the die and the other the size of die to roll. Finding and wrapping my head around the pattern to write to an attribute of a model was my first hurdle.

That set me up for a first serious project. I have been playing a lot of D&D 5e lately and my character sheet has gotten pretty messy. I've been procrastinating on the rewrite, so making a character sheet application that avoids getting messy and can export nice copies is a natural fit.  Also at work, we are thinking about rewriting the proposal submission application, which is a form of similar complexity to a D&D character sheet, with a complex nested data structure and a lot of options. I'd like to be able to say with confidence that we can handle it in Elm and be better off for having used it.

So, I hid away the die roller part of the UI with a style of display:none, but kept it around as the core of an in situ dice rolling part,  and started into the character sheet.

Design spec: This will be a web based single page application, well loosely SPA since a full character sheet for a spellcaster can run to four or five paper pages, and I'll probably be hiding portions away with paging or tabs of some sort. It will be a full character sheet that can handle multiclassing at least up to three classes. It might not go beyond the Player's Handbook in terms of what it supports with known classes and such, but I might allow for typing in some other options. The displayed form on the web should be usable in game from tablet or laptop, maybe phone but its an awfully big form to navigate on a phone. It will have localstorage persistence for offline use and probably use Dropbox or Google Drive as the personal server storage for accessing the same sheet from multiple devices, but I'm not planning to provide a server that users would depend on with all the authentication, uptime, and cost/monetization issues that entails. In that regard, it will autosave the sheet to at least localstorage as changes are made, with syncing to update remote storage whenever access is good. There will be some sort of list selector to choose the character to to load into the sheet, and something to delete unwanted characters. After a CSS design pass, it should print out a pleasant sheet to use. There will be nested structured data for things like weapons blocks and spell lists, but a lot of things that are simple lists like mundane possessions and encounters to remember will just be free text in text areas. It might be worthwhile to support markdown in text areas.

I spent most of my Sunday coding on it, and by the end had about 500 lines of good code that displayed and recorded edits to the model for pretty much all the top level fields. I intentionally put off the nested structures, knowing they would be more complex, and did zero to minimal CSS styling, leaving that for after things basically work.

I downloaded Atom for the editor and a few Elm related packages for it. It mostly worked for me but I was seeing errors from the package that was trying to auto run elm-format for me and did not go down the rabbit hole of working that out. Instead I manually ran elm-format once at command line later in the day, and mostly just tried to code close to what it would output, which slowed me a little bit. Should probably have run it more often. I had the project sitting in my Dropbox for easy access from other machines, so I did not initialize it as a git repo, but will probably do that in my next big session on it.

 It was a very productive flow, using elm-reactor as the dev server and the Chrome browser to see the results. I already love the Elm compiler, which made it very easy to clean up simple mistakes. The debugger was fun to play with, but not too necessary for the simple, repetitive sort of coding I was doing. The workflow for adding a plain text field was very straightforward. Add a line for then new attribute to the model with name and type. Add the new attribute to the initialization record to match the model, with the default value. Add an update message for it to the messages list. Define the function that responds to the message according to one of two patterns, one where it is just text, another where the value needs to be an integer. Add the field and any framing HTML like a list item or label to the view, with the onInput attribute of the field calling the updater message function. Save and go look at the web page to see if it worked or there are compiler errors to fix.  Adding a batch of them at once was easy, the compiler is good at pointing out missing ones in some section, mismatch typos, and similar problems, so I could move along quickly.  Using an editor with syntax color and bracket/parentheses matching support has the usual benefits. Besides something like fifty basic input fields, I did the first dependent attribute calculations to show the die roll modifiers based on the primary attributes

At that point I had two possible places to go - work out the beginnings of persistence to localstorage or start to tackle the deeper data structures beyond placement of H2 headers in the character sheet to show where they would go.

I went with trying to tackle one of the simpler data structures, the saving throws section where it should have checkbox like controls to mark the two that get the proficiency bonus and fields to enter the value. I also started with intent to have a bonus section for special bonuses to saves like from magic items or feats, and to list the source of bonus, but did not expose that part of each saving throw model right away.

This is where I hit the wall. In Elm you can reach down multiple levels by dot notation in getters but not in setters.  So I couldn't say what I initially tried, { model | saves.strength.proficient = not model.saves.strength.proficient } as the update response to clicking the checkbox for the strength saving throw proficiency. Stared at that awhile and started googling for what to do about it.

From what I see, you end up writing a custom setter function that reaches down and updates the innermost record you are updating an attribute on, and the one that encloses that, etc, all the way out. These can be kind of long, so you probably want to tuck them in a module devoted to a related collection of them There is a Focus module from Evan that can simplify this process some, with caveats about performance. There is a blog post about it by Wouter In t Velt that explains how to make some helper functions to shorten it.

But all options are enough of a pain that I didn't move on from there last night, and am considering flattening out the saving throws data structure and possibly doing the calculable dependent values based on character class selection, character level (and thus proficency bonus), and primary attribute modifier, and only making editable fields for special bonuses. The downside is less flexibility for additional character classess. I'll also start looking deeper into the ToDoMVC example to see how to update nested elements that are members of variable length lists like spells and weapon stat blocks.

The take home as a beginner one day into programming in Elm is that Elm is very pleasant and productive to work in if you understand the basics, with a stumbling block once you have to work with nested data models. I expect that is just the first place where I'll be paying back for the benefits of immutability and functional programming. So far though, it feels like a good trade. I want to get back in there and work on the next part.

Tuesday, February 14, 2017

LiveCode and Rogue Stars

For the last couple of weeks I have been preparing (or procrastinating around preparing) for the Rogue Stars event I will run Friday at DunDraCon. One of my main tasks has been to prepare character sheets for two dozen characters. I've been going back and forth about how to do it, all the time wishing I still had HyperCard on a machine that would run it, since it was perfect for that kind of quick layout of fields for a deck of cards database. I considered making a little Rails project but was not in the mood to wrestle CSS to lay it out, etc. So yesterday, I did some searching around the web to see if there was a good current HyperCard replacement for hobby projects. And I found it.

LiveCode is a language and concept descendent of HyperCard. It lets you throw together a UI as quickly as possible by drag and drop, wire up components with a mix of property panel choices and light scripting.  It started as MetaCard, and was Runtime Revolution for awhile. I used Runtime Revolution pretty extensively back at Stanford in the oughts, and found it quite serviceable for scientific projects. When I first hit their site the day before I saw the $1K a year license and said "Nope" regarding getting back in for a hobby project. Then yesterday I saw they have a GPL open source version. Bingo! Download, learn some of the changes in how it works, and I now have an utterly rudimentary character sheets app that does exactly and only what I need to print out a stack of characters for Friday, and about half of the characters entered. It might even be worth spiffing it up a bit and giving it away. I used to make a lot of gaming software in HyperCard, since it was so easy and fun to do.

Here's what it looks like so far (extra points if you spot the data entry error in the screenshot):
That blank space at top right will get a picture of the figure if I have time to take and insert the pics.

Monday, July 25, 2016

3D Printing

The Printable Scenery Kickstarter for Apocalypse Ruins having delivered, I shopped for a 3D printer and ordered a Flashforge Creator Pro from Amazon, kind of a midrange hobbyist printer, with a 4.5 rating a a good reputation for quality, ease of setup, and tech support from the company. Haven't used the support yet, but I can attest to the other two.

I set it up Monday night and learned to print stuff over the course of the week. Two aspects have been particularly tricky, getting the model to stay stuck down and managing curl from differential cooling of layers of bigger objects.

I have a reasonable solution for the first one, melting some of the waste ABS plastic in acetone and painting/smearing it over the print area of the platform to give good adhesion to the first layer of the print. It was the suggestion from online that seems to best match my printer's print bed, though I haven't yet tried kapton tape.

I have some ideas from online and my own thinking re solving the differential cooling issue, will have to work through them over the next week.

Here's my first painted 2x2" scenery tile from the Kickstarter models collection. I like the result and can see working through a lot more of the set.


Quality has improved a lot from the first 3D printers I saw some years ago at Maker Faire.

Here is the first miniature figure I have printed. He's a 28mm Elf Ranger v2 print, a free model by dutchmogul, downloaded from Thingiverse, printed at 0.1mm resolution, the
highest resolution rating of my printer. It's a simple, low detail figure, printed out really crisply. I feel the layer texture with my nail, but I couldn't really see it on the raw print without reading glasses. It's more visible in this after-priming photo, especially on the flat expanse of cloak.  It took minimal clean up effort with my fingers first and then a bit of Xacto knife work. Primed him with a gray mixed from Americana black and white craft acrylics.



Also pictures of both a good small print and a larger one with cooling curl problems on the print bed. The larger roof piece also has secondarily thrashed support material that got stuck to one of the hot nozzles and dragged out of place, some of it sticking through the roof. It's about two thirds of the way through a poor print. I'd already cleared away some of the dragged support mess before thinking to shoot the photo.


7/24/16
5 Photos - View album

Sunday, June 5, 2016

Combat frontage and dungeon design in D&D

Want to make your D&D combat on a 5' grid feel a bit more like OD&D? Make your basic hallway map square a spacious 15' by 15', translating to 3 combat squares across, or assume three guys fit in 10 feet if playing theater of the mind. Why? Well, back in the day, moving on from playing Chainmail to D&D in early '75,  we packed three guys into line to fill a rank in a 10' hallway, based on historical close order infantry like Romans and Anglo Saxon shieldwalls. One 10' by 10' square held nine, not four guys. Two guy could space a bit open order or split the gaps to the walls on either side and hold a hallway without being flanked, since there was no "snap to grid" of 3rd ed and later, but three could pack in and fight as the first rank.

This makes a bit of a difference in dungeon crawls, since except in real chokepoints like doorways, bigger parties didn't become such straggle-fests of characters with their line of sight to the enemy blocked. A typical optimized heavy melee front of PCs and hireling warriors was three with weapon and shield in front and three more with pole weapons or missiles or casters in the second rank.

The 5' grid of later standardization is for the convenience of miniatures play with big single bases after scale creep had driven up the size of figures to 28mm and beyond, often on 1" circle or square bases. Three dinky little 25mm Minifigs or McEwans on close order basing will fit a 10' passage on those maps as long as you aren't sticky-grid about it.

Does it matter? A bit. Besides more guys obviously getting to do something in a basic hallway, and more possibilities for flanking in a hallway fight, if you don't do 15' but do 10' is three squares, fireballs and other area effects are even more lethal, when over twice as many slavering orcs can pack in and be blasted by one.

Saturday, May 14, 2016

The Hiring Hall

Hiring Hall is a new web app I made, drawing on DunGen and DunMap. It's a hireling generator, sort of like Meatshields, which helped inspire me to make it by being down long enough to annoy one of the GMs I play with. Meatshields is quite good. I hope it comes back. But in the meantime, and afterwards for variety's sake, give Hiring Hall a try.

There are some shortcomings with it being a one day project, so far. The names are lifted right out of the namer for NPCs encountered in dungeons in DunGen and DunMap. So they are a bit dark and florid for your usual bunch of torchbearers and mercenaries. The weapons to character class matches are poor for some of the rarer classes, like monks and druids. So edit those when they come up inappropriate. Some of the quirky adjective phrases are out of place in this context, like describing someone as especially well equipped when they roll off the same table as everyone else. Maybe give them a bump in gear if that comes up, or a magic item. I fudged hit points to a D6 + 1 for all mercenary/soldier types, 1d6 for noncombatant servants, and D8 per level for fighter type classes and D6 per level for other levelled classes to keep the coding down.  There is room to add a lot of customization controls, and option in the historical names lists in place or in addition to the syllable masher. All of this stuff is grist for iteration.

But it generates NPCs. Some of them make me laugh out loud when I consider using them. That's a win. And it got me coding game stuff again and some of the data structures I added to equip characters for it can feed right back into DunGen and DunMap.


Thursday, May 5, 2016

Something I have always wanted to do...

I have shied away from attempting landscape painting for decades. Painted hundreds of minis, lots of table top terrain, and not one painting to backdrop it for photos.

Until yesterday.

I took some photos Sunday of my layout for my first game of Andrea Sfiligoi's Of Gods and Mortals*  that I quite liked but the background room clutter really detracted. I started thinking about how I really ought to get started with the airbrush and make a backdrop to hide the clutter for better pictures. Whited in the sky on a couple of handy still-flattened box lids Sunday. Well, I backed off on learning to airbrush too and finished the first painting as a regular brushed painting with some cheap craft store acrylics I usually use for terrain last night. I'm pretty happy with the mountain, not as much with the clouds. But now I know I can do something good enough to use. With the dam broken, I can start getting better. And maybe start learning that airbrush too.

Anyway, here it is, proof of concept...

The painting by itself. Yeah, the box lid folds and corrugations show. But it is basically a throwaway learning piece. Took about an hour and a half maybe. I was in the zone and really don't know. There are some little flecks of white still there from a stupid ancient bottle of blue paint whose lid crumbled to plastic dust as I tried to open it. Got most of them off...

Anubis in a fearsome aspect.
I learned that having tall shadow casting terrain and a sharp board edge in front of the painting is a bad idea. Could take down the towering bits and plunk some lichen or rocks down at the board edge to break the flat line . But hey, he's awesome, so I want a picture here of him until I take a better one! He's an old Diablo-related action figure that I based up on two bases, one for each foot, since he is so big, and could stand, if unstably, without any base at all.


Sobek's left flank guard is the mighty BOAR CROC!



I think my next one will be on foam core to be wider and still lightweight, and not have corrugations to show through. Maybe do two so as to be able to line a 6 foot table edge?

(Thanks to the guys that reported the pictures problem. I was able to see in from Safari on my work machine. I have re-uploaded the broken images by another path and will see if they are visible soon.)

* Published by Osprey. More on the Anubis vs Sobek game I'm doing with it in my next blog post. I think its going to rock.

Thursday, April 7, 2016

The Quicksilver Bow, a Magic Item

The Quicksilver Bow was crafted for the werewolf hunting ranger Ivar the Night Stalker by his friend Venable the Mad Wizard. It looks like a finely crafted composite bow with silver inlay that ripples and shifts over its surface like the patterns on a cuttlefish. It provides no bonuses to shooting or damage most of the time. When drawn against a werewolf or other target that is vulnerable to silver arrows, some of the quicksilver flows over the head of the arrow, silvering it on the fly.

Ivar found great success using the Quicksilver Bow for over a decade, in an illustrious career of surprising duration for a man so frequently endangered by werewolves, but all things have their costs and he eventually succumbed to heavy metal poisoning.  Mad as a hatter for much the same reason, he was imprisoned on a particularly bad day by the city watch of Fellstein. Long and repeated use (on the order of  several years) will afflict PCs similarly.

It is rumored that Venable also made a Quicksilver Sheath that treats the longsword drawn from it the same way if it is drawn in the presence of a creature vulnerable to silver weapons.

Friday, January 29, 2016

Frostgrave at DundraCon

So, I have been silent on the blog for over  a month now, what have I been up to?

FROSTGRAVE!

I'm scheduled to run Frostgrave at DundraCon, Friday Feb. 12 at 4 PM. I expect it will go two rounds with a campaign turn in between and one at the end. The maximum player count I set was eight, so I will have two tables going, either as two 4 player games or four 2 player games. It will be starting warbands with 500 GC. You can bring your own, and I'll have figures for eight pregens set up, with a list for each school of wizard. I've been working a lot on scenery to give it that Frostgrave flavor. Here is a vignette shot on terrain a recent practice game, as an example:



















An earlier practice game before the round towers got painted:



















And here is a shot of my painting table with treasure markers and guys in progress:



And some scenery in progress:




Tuesday, December 1, 2015

Annoying Magic Items

Tonight, while digging for other things, I came across a sheet of paper with a list of mostly flawed magic items I wrote out in one of those silly DM moments. Apologies if this is an inadvertent reblog.

Con-man Sword I10 E12, no other powers but talking, pretends it can Detect Slopes, Traps, Gold, Gems.

Potion of Levitation without vertical hold, you rise and rise until it runs out.

Magic Sword which drains XPs you would normally gain upon killing the monster.

Telepathy Crown which warns the opposition.

Horn of Plenty yielding Spam.

Sword of Chaos- Powers change with each being slain, shapeshifts. Needs a powers table or just roll on the magic swords table each time.

Lightning Whip - hit self on fumbles.

Addictive Potions - probably of Healing

Lightning Wand with a short. 1/6 chance of self zapping.

Coin-op magic sword - pay to play. +1 bonus for a GP for 1D6 rounds of combat, or make it eat a platinum or gem and give it a higher bonus.

Defective Portable Hole, eats stuff on 1/6, or 1/3 if really fritzing out.

Strength Potion - Adrenalin-like with power rush and weakening crash after duration runs out

Flying carpet with a penchant for acrobatics.

Animated shoes

Dragon gecko - changes when it hiccups.

Items which convert H.P. to spell levels.

Casting amulets give a bonus to casting rolls. - huh, a normal one slipped in...

Hangman's Rope - The rope is thick and coarse, its rough fibers make it painful to grip. It has a noose at one end, caked in brown, flaking blood.  It has a pompous magic activation phrase ", It is thy day to die." If no name is mentioned in activation,  it randomizes among all beings within 30'. Its reach is 30'. It uncoils quickly and moves fast, striking in a single round, hitting on 8+ on D20. Dex save on D30 to dodge. It jerks the victim from the ground and hangs him for 2D6 damage in the first round and 1D6 each subsequent round, AC 2 and 20 HP that will heal at the next new moon. All attacks or other action rolls by the hanging victim are at -2. If found enshrined, there will be an archaic inscription near it that tells a story of a hanging that includes the magic phrase: "Spake the Charnel Lord: ABROM! It is thy day to die. And the Hangman's Rope did lift the man to kick and jerk his life away. Eyes burst from their sockets, black tongue bit half through, he was dropped to earth and given to its cold embrace."

and... a couple of house rules ideas:

Impediment by weapons - can carry/wear 3 hands worth okay, -1 Dex and To Hit for each further. Alternative to detailed encumbrance, would need more when packing a lot of loot/provisions.
Daggers count 1/2 hand
Handaxes 1/2 hand
Shortbow 1 hand
Longbow 2 hands
Light crossbow 1 hand
Heavy crossbow 2 hands
Most shields 1 hand.
Large, heavy shields 2 hands.
Other weapons 1 or 2 hands as needed to wield them

A casting variant for semi-Vancian magic, where most spells are memorized to be reasonably reliable and safe, but others can be cast in a crunch. This was with an INT or WIS roll to cast. Pretty close to what was in my previously blogged 80s OD&D campaign house rules.

Casting unmemorized spells
-2/level of spell on casting roll
Caster takes 1 hit point of damage taken per level of spell attempted
Wipes memory of equivalent in spell levels.

Casting beyond listed number of spells for that level (Crashing for power):
Casting Roll modified as above for unmemorized spell.
Caster takes 1 hit point/ level for the attempt if casting roll failed.
Caster takes 1d6 damage per spell level if successful.

Preparation -
Gain up to 1D6 bonus on chance, rolled secretly by ref at 1 point per full turn of preparation with expenditure of 1 GP worth of magical supplies/turn/level of spell



Thursday, November 19, 2015

Thugs and Ruffians

I'm at the tail end of a cold that kept me home a couple days. Looking forward to going back to work tomorrow. Whiled away some of the time painting and G+ chatting with some other minis painters in a chat organized by Kurtus Brown, muting my mic when the coughing got bad.

 Here are the guys I took from about halfway to pretty much finished in chat sessions. Also did some putty filling on the GW Oculus and sculpting stonework on a tower wrapped around a cocoa mix can. I'll show those pieces later. They're propped against the palette here to face them up into the light to cut down on shadows. They'll get a spray coat this weekend and then I need to pick out a skirmish set of rules to try with them and some older ones.