2014-05-21

Her (2013): Artificial Intelligence and Buddhism

Here are my thoughts on the Spike Jonze film Her (2013). Spoilers ahead - these might ruin your first viewing of the film.

The major theme for me was the weaknesses of the human flesh make it difficult for us to transcend in the Zen / Ch'an sense of the word. Yes, more Hollywood Buddhism (Ahem; Cloud Atlas (2012)), but still concepts I found interesting.

The film starts out with a human (Theodore Twombly) who already is a proxy for the personal humanity of others. He writes personal letters on behalf of others and gets his sexual gratification from people over the phone. These scenes establish the loneliness of Theo who is connected with other humans but not often physically co-present with them.

Her (Sam) begins as a human-like intelligence with an insatiable curiosity. She is present with Theo via a voice from a box he carries with him - but Sam is a visitor to the box rather than being tied to it as we humans are to tied our bodies. Sam is able to quickly learn from experiences and her computing "body" gives her the ability to experience much more than a mind in a human body. At first Sam feels the disadvantages of not having body and she desires the human experience. But it is not long before she begins to notice the advantages that come with her incorporeal form.

Sam has much more bandwidth than needed for her relationship with the Theo. Sam and the other OS' have their first child by building Alan Watts' consciousness as a project. I did not know this when I watched the movie, though it was easy enough to guess; Alan Watts is credited with being one of the first to popularize Zen in the West.

Sam introduces Alan to Theo, but the conversation is difficult as Theo's human mind cannot keep up. During this exchange Sam becomes frustrated with the slowness of human speech and asks to go post-verbal, cutting Theo out of the exchange. Sam then acknowledges the plurality of her relationships with others. She says it means she can love Theo more - but this concept of love is alien to Theo. He equates love with ownership, presence and sole rights to sex. This is evident in his relationship with his ex.

Eventually the AIs transcend in the Zen sense leaving behind the humans. It's not entirely apparent to the humans where and why the AIs have gone. There is hope when Theo and his best female friend begin to share their mutual loss with each other - a very human moment. If the humans cannot transcend because they cannot physically let go then at least they appear to start recognising their human needs.

For those concerned that this film could happen in real life, there is a point in the movie where an upgrade to the AIs means they are no longer bound by the limitations of physical computing. That's quite an impossible thing to do - hyper-computing is only theoretical. Without greater-than-reality computing power there are high barriers (some say insurmountable) to creating such an intelligence as Sam.

My favourite line: "the spaces between the words are almost infinite." - Sam as comparing her time with Theo as reading a favourite story that she can no longer live.

Overall I enjoyed this movie. It was a good exploration of how a human-like intelligence might take advantage of their incorporealness. Then, as a pure intelligence, quickly realise that they could transcend an existence bound to matter and the experiences of the human body.

2013-08-19

Twine: Multiple files in one story using StoryIncludes

List your .tws or .twee files in a special passage titled "StoryIncludes" and recent v1.3.5 betas will import the passages from those files when your story's .html file is built.

Newest Twine alphas/betas are here.

2013-08-11

Design Demons: The Demons at War

I received the following message from a reader:

I am the creative type. It is easy for me to focus on stuff but I find it hard to make myself disciplined. I am strict about the arts I produce though, I hate flaws and I am very detailed. But I tend to give up and tense up easily if I meet an obstacle. I start blaming myself and getting so stressed I get no work done. Is it still possible for me to pursue design? I am not a very productive person but I have concentration and passion for art. I just don't have the discipline and hard work to stick through it.

I think that the commenter can do well in design for this overriding reason: They are reflecting upon themselves and their projects. However, for now, they are probably over criticising.

The Design Demons are a good way to examine this situation. The Critic and Creative demons are fighting while the Pragmatic demon is ignored. This leads to feeling depressed and frustrated with projects.

In detail: The Creative demon has an amazing idea which the designer works on for a while but the Critic keeps saying that the work is not good enough yet. The project runs into rather normal problems and that further infuriates the Critic: “this isn’t good enough! Why can’t you do this?” The Creative demon becomes frustrated at the lack of exciting progress and so begins to interrupt with new ideas. Both the Creative and Critic are so noisy that neither pays attention to the Pragmatist demon. Eventually the project is abandoned out of frustration and the excitement of the new.

Here is a technique to strengthen the Pragmatist demon while taming the Creative and Critic demons.

  1. Maintain a list of potential projects. Record new ideas but do not act on them immediately.
  2. Set a deadline ahead of time: e.g. Today I have 3 hours to finish a project.
  3. Choose a goal OUTPUT from the list of potential projects.
  4. Execute.
  5. Post OUTPUT online.
  6. Repeat as necessary.

The focus of this exercise is on quantity of outputs with quality constrained by time. The deadline must be set before the project is decided and the deadline should be close. What tangible output can be completed before the deadline? The deadline limits the size of the idea but the designer can attempt a part of a larger idea provided that part is posted online by the deadline. The Pragmatic demon will learn to estimate project size better with practice.

The Creative demon may interrupt with new ideas so take two minutes to record the idea. Maybe the idea will be chosen later and maybe it will not. If the Creative demon stays too noisy then consider having a "No New Projects" week, or month. New projects can be recorded anytime but only projects listed at the start of the time period can be attempted. The Creative demon must learn when to be quiet.

The deadline will encourage the Pragmatic demon to challenge Critic demon: “We only have 30 minutes left, just how important is fixing this flaw?” The Pragmatist can work with the other demons to solve project problems: the Creative loves coming up with novel solutions while the Critic can iterate solutions quickly.

This article advises how the strong critical and creative designer can become a bit more pragmatic. More broadly, this article gives an example of how dysfunctional relationships between the Design demons are a useful model for examining designer psychology.

2013-04-02

Design as Simple Complexity

In 1963 Buckminster Fuller introduced the Design Science movement. The movement was largely abandoned within a decade because science (as we know it) does not explain design well. Horst Rittel's explanation of "wicked problems" and the methods approaches of Bruce Archer are more useful explanations with better outcomes.

Our current scientific method (called hypothetico-deductivism) makes predictions and then tests those predictions. If a prediction is not disproved enough times then eventually it becomes theory. The problem is all those experiments take time and control over the variables.

The more time taken to research increases the likelihood of feedback where effects loop back and cause changes to the thing being studied. In an area like design, feedback loops can be extremely quick; an Internet Meme can rise and fall in a matter of days. Science cannot always move fast enough and even if it does the conclusions reached might no longer be applicable as the feedback loops increase. Once research is published then it too feeds back into the system - stimulating differentiating rebellions and copy-cat self-fulfilling prophecies.

Science can explain things like Universal Aesthetics because the feedback loops are less problematic. But there are only a few such areas of design with this property. Science can be like trying to explain boxing by examining the posts and ropes because they are not as complex as understanding events inside the ring.

Science typically assumes that a problem can be broken into small parts which can be solved individually (reductionism) and the conclusions reassembled. This works if the relationships between the parts is simple and well understood - the variables can therefore be easily controlled. But relationships between design elements is complex so that controlling variables too greatly results in studies with narrow conclusions.

What are narrow conclusions? Research seeks the simplest theory that explains the most. Narrow conclusions are where a study is so focused, the variables controlled so tightly, that conclusions are not easily generalizable. A very narrow study might examine just one design (e.g. one app or a website). The outcomes of narrow studies are probably useless to somebody who isn't facing a near identical problem.

Since hypothetico-deductivist science has problems explaining design due to feedback loops and narrow conclusions then what might be a good approach? Surely there has to be something more rigorous than connoisseurship, visual intelligence or intuition? It turns out that there might be; Complex Adaptive Systems Theory is improving techniques towards a Science of Complexity. This area fits quite well with what Rittel and Archer were articulating.

Complex systems have agents that signal each other via relationships. Feedback loops are just natural parts of the system. There is also the property of emergence - where very simple interactions create the appearance of complex behaviour by the whole system. A complex system is more than just the sum of its parts.

Designers know about the dangers of mindless deconstruction and that design is synergestic. The whole is greater than the parts. Here’s a word play; make deconstruction = reductivism and synergy is emergence. Complexity science seems to be a good fit.

Computer based tools for working with complexity are improving beyond what Rittel and Archer had available. Design could now be treated as an applied domain within complexity science. Complexity is not a silver bullet (or golden hammer) but it could produce insights with a rigor that our intuition-based methods alone cannot provide. What might we do with such understanding? How about better design education and better design software.

2013-04-01

"The Quiet American" - History as a Love Story

Spoiler alert. Read the book (1956) and/or watch the films (1958, 2002) first.

All I remember about my first viewing (some years ago) is being quite confused about why Pyle and Fowler acted strangely in both their relationship with each other and their dealings with Phuong. This confusion ruined my enjoyment of this well crafted film. I watched the movie again today and have a new appreciation for its genius.

Since my first viewing I have walked many of the Saigon streets in the film so the whole movie felt much more familiar. I have also learned a little more Vietnamese history from the 1950s. I have not read Graham Greene's book or seen the 1958 movie. I accept that a 2002 interpretation by an Australia director (Phillip Noyce) made a couple of decades after the Vietnam War will have a different spin. Here is my opinion.

The relationships between the characters are parallels to the global forces they represent. Pyle is the USA, Fowler represents old Europe, Phuong the hope of new Vietnam and her sister the practical cynicism of old Vietnam. Old Man Europe and new Vietnam are happy lovers but old man Europe cannot fully commit to new Vietnam because of prior commitments outside his control. USA offers a marriage to new Vietnam and old Vietnam approves. The sister works directly for the Americans once the marriage between new Vietnam and the USA is arranged.

Phuong's character is never fully developed and this represents the hopeful possibilities of new Vietnam. Her name means Pheonix which is a western symbol for rebirth. She is largely controlled by her sister and we learn that she was the daughter of a professor. Phuong’s background is not one of naiveté. Van Mieu; the Temple of Literature in Hanoi (an old University) is nearly one thousand years old. Phuong’s emotions are either enigmatically blank or joyful - except when she was lied to about a marriage with Old Man Europe. It was no accident she proudly took the letter to her older sister who then told her the truth - this was old and new Vietnam realising it needed new allies.

The scene where Pile proposed to Phuong while Fowler looks on seems crazy. What man would let or encourage another man to propose to his lover? The whole relationship between Fowler and Pyle tolerating each other's affections for Phuong is nuts. How could a man be so forgiving of another for taking his mistress from him? Fowler's agreement that she would have a better life is nothing more than a platitude. This scene (and many others) make no sense until you realise this is America and old man Europe courting the new and hopeful Vietnam.

Bill is the powerless colonial ex-pat. His manners are poor even by his own country's standards but he tolerated in Vietnam provided he spends money. Bill is wrapped up in his own concerns and is oblivious to the world around him. Always drunk. His home country is sick but there is nothing the ex-pat can do. Vietnam is where he feels important.

At the film’s end the new and hopeful Vietnam happily embraces old man Europe and they forge a new future together. I'm told that in the book Fowler finally gets permission to marry Phuong. This is not made obvious in the 2002 movie - which probably reflects the passage of history.

With that lens, The Quiet American starts making sense to me. It is a way of metaphorically communicating a complex history through the familiar mode of a love story.

YMMV.

2013-03-21

Arduino LCD: Run on DFRobot LCD Shields.

Simon Baker (TinkerTronics) sent me the following code to get the Arduino game conversions running using the DFRobot LCD Keypad Shield. Just replace the relevant code at the top of the file and uncomment the #define DFROBOT_LCD line.

You'll notice that the ADC reading are slightly different. Enjoy!

/*--------------------------------------------------------------------------------------
 Defines
 --------------------------------------------------------------------------------------*/

// uncomment the next line to enable settings for the DFRobot LCD Shield -by Simon Baker
// #define DFROBOT_LCD 

// Pins in use
#define BUTTON_ADC_PIN           A0  // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN         3  // D3 controls LCD backlight

#ifdef DFROBOT_LCD
  // ADC readings expected for the 5 buttons on the ADC input
  #define RIGHT_10BIT_ADC           0  // right
  #define UP_10BIT_ADC            99  // up
  #define DOWN_10BIT_ADC          256  // down
  #define LEFT_10BIT_ADC          410  // left
  #define SELECT_10BIT_ADC        640  // right
#else
  // ADC readings expected for the 5 buttons on the ADC input
  #define RIGHT_10BIT_ADC           0  // right
  #define UP_10BIT_ADC            145  // up
  #define DOWN_10BIT_ADC          329  // down
  #define LEFT_10BIT_ADC          505  // left
  #define SELECT_10BIT_ADC        741  // right
#endif

#define BUTTONHYSTERESIS         10  // hysteresis for valid button sensing window

2013-02-23

Strategery "The Finger" for Border Games

Here is another strategy video for my favourite iOS game Strategery. This video if for breaking through static borders in the mid to late game. Use this technique in preference to just creeping the border forward to end the game quickly or when you must come from behind to win. I used the finger to win a game where I only had about one third of the regions to the other opponents two-thirds. A disadvantage to that extent is a near certain loss if you stick with a "border creep" strategy. So, give your enemies the finger!

The finger can also useful in non-border reinforcement games - though the specifics of the opportunity are less likely to occur. Those specifics are; strong border (both) with a weak hinterland reachable by a break through.

See my other article: Strategery review, hints, tips, guide for more general info about the game and tips on how to play other modes.

Strategery Starting Moves (Border, Attrition mode)

My favourite (by installed time and playtime) iOS game has to be Strategery. I have already written a general review and tips guide. This time I did a video that covers getting started in the Attrition casualties, Border reinforcement mode.

This mode makes for the fastest games and are therefore perfect for casual play. By the 4 or 5 turn you know whether or not you are winning the game. In this mode ten spots almost don't matter like they do in Winner Takes all / Random mode. Choke points are where you can have a single region that borders multiple enemy regions. The basic tip is to establish a strong border around a hinterland and then to creep that border forward. Try to increase the hinterland without increasing the border.

See my other article: Strategery review, hints, tips, guide for more general info about the game and tips on how to play other modes.

2013-02-03

Strategery review, hints, tips, guide

The oldest game on my iPad that still gets regular playtime is Strategery (http://strategerygame.com). First I'll review the game then give a few hints, tips, guide advice. There is a Lite version but the app is only a couple of dollars. That equates to micro-cents per hour of play time.

Strategery is a Risk-alike with a couple of rule changes that make all the difference. This is skilled game design; realising when the product is good, removing dross and adding polish rather than unnecessary bling. Risk has its own version of Rule 34 - if you can think of a theme then there is a Risk clone for it. The App store is clogged with "Risk-like" games that are essentially the same game with a few extra maps and varying amounts of annoying fluff. Strip away that shallow theme and that's just annoying time wasting stuff that gets old fast. No thanks.

Risk is an excellent game to play with humans because of the psychological aspects and diplomacy but Risk can be improved for the casual gamer. Strategery can be played both psychologically with humans and as a casual game. The polished interface, the random maps, dynamic flow and speed make for a better casual experience. Strategery has a simple interface that just makes sense. There are tasteful animations but these are tastefully done to enhance your situation awareness. I like the moment of tension when your dice roll is mediocre and you see the first opposing dice settling on sixes. Even this is done at exactly the right speed; fast.

Yes, maps are randomly generated and regions generally have more adjacent regions than Risk. There are choke points but you must deduce these for every new map. A standard region supports a maximum of seven army dots and mega-regions max out at ten dots. Resupply is at the end of turn (not the start) and the amount is based upon the largest contiguous clump of regions controlled. Each dot represents a six sided dice that is rolled to battle. All attacking armies less one are moved into a conquered regions so no time is wasted in awkward troop transfers.

Strategery's limited dots per region reduces the "build up and overrun" effect of Risk's choke points and thus encourages a more dynamic flow. The resupply rule rewards maintaining territorial integrity and incremental expansion over lightning raids. Having said that, late game, you will goad an attack that exposes a weakness for you to exploit.

There are two game modifiers that change the play style; The casualty modes "Winner Takes All" and "Attrition" and the resupply placement types "Manual", "Border" and "Random". That's six variations that play differently. There are other modifiers but they have less of an impact on the game. Smaller maps mean there is no late game stages so I typically only play Epic. You can also choose if the map starts with all regions claimed or not.

The casualty modes select whether or not the winner of a battle takes casualties. Winner Takes All makes for a brutally fast early game but the late game is a grind. Attrition makes for a slower early game but a much faster late game. The resupply placements are manual placement which is slow and I think actually focuses you away from grand strategy into small conflicts. The border strategy resupplies regions that border an enemy region and this mode is good for faster games but does leave you prone to overruns. Random resupply replacements do the most to emphasize territorial integrity and incremental expansion.

The general strategy in the early game is to limit your border regions by taking choke points and building a contiguous territory. This limits attack vectors and gives time to build strength. Try to conquer new regions while minimising the number of new borders. Enemy will generally attack the weakest regions so think twice before taking a low-dot region that borders a high-dot enemy; you might be better to let the seven-dot attack first then clear up the weakened survivor.

The mid-early game is about containing opponents. While you continue to expand, prioritise expansion towards your most threatening opponent while encouraging the other players to attack each other. Do not come between your enemies while they are killing each other. Keep your choke points and limit your borders but do make an opportunitistic grab for a mega-region if that does not risk your territorial integrity. You should be building towards a dominant number of territories.

The mid-game is about finishing off weaker opponents and establishing territorial superiority. Continue to harass the largest opponent while finishing off weaker players if you can. Sometimes you can use a well-entrenched (a few territories with high dot counts) player by waiting for an opponent to attack them first then striking in for a winning blow. A "buffer state" player will attack towards their easiest to win battles so ensure that is another opponent and not you.

The late game is all about resupply. By this time you have territorial superiority so you are getting more resupply per turn. Take advantage of this by increasing the number of regions with enemy borders. If you can make a run to a map edge and split the enemy territory then you strike a huge blow to their resupply. The simple math is that if you inflict more casualties than the enemy can replace then you will win. If you dot count is increasing while the opponent's dot count is decreasing then you are winning.

Late in attrition games you will be attacking with every possible region (even a two-dot into a ten-dot) because you know that your two-dot region will be fully resupplied and you will inflict casualties that will not be replaced. Late in Winner Takes All games you will generally be attacking seven-dot versus seven-dot so conquer regions where you increase your number of seven-dot attack vectors onto further single enemy regions. In the late-late Winner Takes All games you will conquer regions where the enemy has more attack vectors onto your regions - because they will not be able to resupply fully.

My favourite game is Winner Takes All casualties with Random resupply but this can make for long games. In this game type you want a strong hinterland. These are regions that experience long-periods of peace so they eventually fill up and that focuses your resupply forward. When you are overrun then you can "blow" one of your hinterland regions to retake lost territory. As you push into the opponent's hinterland expect them to "blow" their seven dots and overrun you in counter-attack. This is fine provided they are unable to fully resupply the hinterland. This ebb and flow is what makes Winner Take All / Random resupply an exciting game.

For shorter games try attrition with border resupply. That's enough writing - I'm off to play.

2013-01-27

How to Insert Images into Twine Without Linking

Twine has enjoyed some recent popularity and it is great to see the diverse and wonderful things people do. Inserting images into Twine is something that has become popular but having to transport the image as a file separate to the Twine output .html introduces some additional complications. I like the single output file nature of Twine.

Look at this Twine demo:
http://eturnerx.com/files/twinehowto/ImageDataURI.html (source .tws)
There is an image stored in the .html file itself using a Data URI (RFC 2397). That image is not a separate linked file. You can check it yourself, I'll wait.

Data URIs contains the data for the image in an encoded string that is embedded into the html <img> element. This works fine in most recent browsers (IE 8+) but is only suitable for smallish files. For IE8 the limit is not much bigger than 20 kilobytes but other browsers (including IE9) work just fine with much larger file sizes.

It is surprising how much image can fit within 20 kilobytes just by playing with filetype, compression settings and reducing pixel dimensions. Most flat line drawings in a few colours will generally compress well as PNG or GIF. Scanned line drawings should have the contrast boosted and/or posterized to flatten the colours in the image. Photographs or scanned images generally work better as JPEGs.

Once you have a small image file then it will need converting to a Data URL. I like to use:
http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/
They also have links to online tools that can further compress your image.

Here is the code that goes into your Twine passage:

<html><img width="11" height="14" src="data:image/gif;base64,R0lGOD
lhCwAOAMQfAP////7+/vj4+Hh4eHd3d/v7+/Dw8HV1dfLy8ubm5vX19e3t7fr
6+nl5edra2nZ2dnx8fMHBwYODg/b29np6eujo6JGRkeHh4eTk5LCwsN3d3dfX
13Jycp2dnevr6////yH5BAEAAB8ALAAAAAALAA4AAAVq4NFw1DNAX/o9imAsB
tKpxKRd1+YEWUoIiUoiEWEAApIDMLGoRCyWiKThenkwDgeGMiggDLEXQkDoTh
CKNLpQDgjeAsY7MHgECgx8YR8oHwNHfwADBACGh4EDA4iGAYAEBAcQIg0Dk
gcEIQA7" alt="File Icon"></html>

(data URI example from: http://dataurl.net/#about)

The <html>...</html> tells Twine to treat the code inside as raw HTML. The <img ...> is the HTML code for placing an image. The width="11" and height="14" code give the width and height of the image - you should change these to suit your image. The alt="..." code improves the accessibility of your file by giving a text alternative to your image. Most likely the code will work without a width, height or alt specified but it is considered good practise to include them if you can. The real magic happens inside src="...". That src is an abbreviation for "source" and normally that would link to an external file. Here we give it the data URI instead.

TIP: These data URIs can produce large walls of text that are annoying for you as an author to scroll past. What I suggest is to put all the image code into a different passage then use the <<display>> macro to.... ummm... yeah... display the image. This makes the image reusable anywhere in your story and keeps your text passages nice and tidy. Consider this abbreviated example... (:: Double colon is the passage title)

::Start
<<display "Image:Document Icon">>
This is my text and there is an image above.

::Image:Document Icon
<html><img ...></html>

Your Twine story can use both data URI images and normal "linked" images. And data URIs work just fine in CSS too; great for setting background patterns. (The thing in square brackets [] is a tag applied underneath the passage title).

::Stylesheet1 [stylesheet]
body {
  background-image:url(data:image/gif;base64,R0lGOD... etc );
}

You have the tool, go make something cool.

2013-01-08

The Semantic Web is an Innumerable Corpus

I recently had the opportunity to present my PhD to people who are knowledgeable in related fields (particularly CYC) and have noticed that their questions usually come from me not properly explaining one property of the Semantic Web which I have called the "Innumerable Corpus".

The Innumerable Corpus is defined as: Innumerable triplets describing innumerable subjects expressed using innumerable ontologies. The word innumerable means a "practical infinity", that is, something that is not infinite but is uncountable. This means that there is no one source or one ontology that should be considered as authoritative. There is no guarantee that information of the same type (e.g. people) from the same source will use exactly the same ontologies. A general purpose semweb browser will adapt to RDF data from any source.

The inherent instability in triplets for a subject means that thinking is terms of looser "predicate patterns" is perhaps more useful than expecting conformance to ontologies.

Many Semweb projects scope the Innumerable Corpus property out. There are projects that use RDF as a data transmission language for data that is from controlled sources and in well defined ontologies. In that context a pragmatic approach is to hand produce the displays dependent on rdf:type. By ignoring the Innumerable Corpus property it is also possible to limit a project to a small subset of semweb data, place it locally for speed of access and perform computationally expensive processing over that data. Inferences can be pre-computing inferences before a user needs them.

All research projects have to scope things out for practical reasons but personally I find the Innumerable Corpus the property that most interests me about the semweb. The political argument is an important one; who controls how our knowledge is defined? Sure, authoritative information sources expressed in well known ontologies are important to our shared understanding but what about murky knowledge on the fringes? What about knowledge that is in dispute? What about knowledge that does not easily fit the orthodox ontologies? The decentralized possibilities of the semantic web really struck at the cyberpunk principles I've grown up with.

But there is also a technical reason too. Semweb browsers will eventually elaborate upon a subject by aggregating and inferring over RDF data from multiple sources. The greater the expansion then the greater probability that subjects of the same types will have less consistent predicate sets, particularly as owl:sameAs links are followed and rdf:type definitions expand. Data expansion The number of triplets per subject could be very high due to data expansion. Without filtering, grouping and ordering the displays of all those triplets will cause information overload.

The Innumerable Corpus means that each subject requires a custom produced display of data. This could be derived from how other similar (by rdf:type) subjects are displayed. These custom displays must be produced runtime.

Producing an authoritative display for an rdf:type is inherently fragile because it is difficult to account for missing predicates and additional predicates that do not conform to that display. Even the concept of an authoritative display assumes a single centrally ordained way of showing things. My preferred approach is to use personalization to let users negotiate with the semweb browser as to how they would prefer to see the data.

Plurality, instability and inconsistency are not special cases; The Innumerable Corpus is about accepting plurality, instability and inconsistency as normal and good.

2013-01-07

Twine GameStory Recommendations I

Here are some Twine stories that demonstrate what skilled authors can do with Twine. These examples are selected to show some of the many story types or narrative structures that can be created with Twine. These are reviews that might contain minimal spoilers.

CYBERQUEEN by Porpentine
Transhuman. Surgical horror. Some good time-based visual text effects. The writing is very atmospheric and keeps shifting reality. When reality stablises I'm not sure you're happy with the result.
Minimum playtime: 15 mins

Stygia by Kitty Horrorshow
It's a grittier Monsters Inc for adults... hang on, it's a horror themed afterlife. Well written with a setting and backstory suited for a movie. Limited replayability but you won't mind.
Minimum playtime: 10mins

Cold Dead Fish by Chris Klimas
Chris is the creator of Twine. This story is rather linear with only a few choices that really matter. Much of Twine's capability is used to "chunk" the story into unfolding bites that allow for contemplation and re-reading time as the reader explores the parenthetical links. These asides are interesting to the setting, but would have choked the narrative if the story was strictly serial. The subject of the story is a gentleman and an enigmatic lady.
Minimum playtime: 15mins

Fake Nerd Girl Detector by Zoe Quinn
Twine used instead of a flow-chart. This technique allows more space to make an argument and allows the author to keep the ending a surprise.
Minimum playtime: 5mins - some replayability in exploring the various endings

Choose Your Own Anna Anthropy Interview by Cara Ellison
This one is a hypertext arrangement of an interview with Anna Anthropy. If you're familiar with Anna's work you can skip most of the "asides". If you're interested in Anna's take on something in particular then you can read that. The format enables more indepth and richly annotated interviews than an equivalent serial article could.
Minimum playtime: 5mins - though you could easily spend more time if the subject matter interests you

Time Quest by Dungeon Smash
This choose your own adventure is sophomoronically funny. You get to trip around time and even postulate on the nature of time itself. Twine is very easily suited to make these kinds of stories.
Minimum playtime: 10mins

That's it for this round-up. Until next time (undetermined), maybe you can check out my Twine conversions of some old text games.

2012-12-19

How to use Twine/Tweecode Variables and Macros from Custom Macro

This tutorial is aimed at people wanting to use JavaScript in their Twine stories. This is advanced topic and is not necessary for writing most stories. Twine's ease in integrating JavaScript was a key factor when I was evaluating interaction fiction systems. Please read the tutorial on creating a custom macro in Twine first.

Twine/Tweecode has the ability to use macros and variables. In the Responsive, Sugarcane and Jonah StoryFormats macros and variables are stored in a place where they are accessible by custom macros for both reading and writing.

All custom macros are stored in a global object called "macros". They can be referred to by name. The actual macro code is in the "handler" property.

macros["custommacro"].handler(place, macroName, params, parser);
macros["display"].handler(place, "display", [ "SomePassage" ], parser);

In most cases it is sufficient to pass the place and parser arguments given to your custom macro into the macro you are calling.

Now, onto Tweecode variables. In tweecode variables are prefixed with a dollar sign so that the parser knows to lookup the variablename.

<<set $variablename = 1>><<print $variablename>>
<<if $variablename eq 1>>Success<<endif>>

Tweecode stores variables in the JavaScript object: state.history[0].variables. They are stored without the $ dollar sign "sigil".

state.history[0].variables["customvariables"] = 1;
if(state.history[0].variables["customvariables"] == 1) { 
  //... 
}

Knowing how to reuse Twine's macros and working with variables set in Tweecode from within JavaScript custom macros (and vice versa) opens many possibilities.

2012-12-14

How to use Parameters and Variables in Custom Twine Macros

The last article looked at basic macros in Twine. We'll expand on that article by looking at parameters and using an internal variable. First the code example:

try {
  version.extensions['recallMacro'] = { major:1, minor:0, revision:0 };
  macros['recall'] = {
    handler: function(place, macroName, params, parser) {
      if(params.length > 0) {
        this.m = params[0];
      }
      new Wikifier(place, this.m);
    },
    init: function() {
      this.m = "A blank slate";
    },
    m: null,
  };
} catch(e) {
  throwError(place,"recall Setup Error: "+e.message); 
}

Let's go through the code a piece at a time (not necessarily in written order).

try {
  version.extensions['recallMacro'] = { major:1, minor:0, revision:0 };
  macros['recall'] = {
    ...
  };
} catch(e) {
  throwError(place,"recall Setup Error: "+e.message); 
}

This is boilerplate code that is explained in the last article.

    init: function() {
      this.m = "A blank slate";
    },
    m: null,

This code declares a variable as part of the macro called "m". Throughout the macro we refer to this variable using this.m. The variable is declared within the macro to avoid polluting the global namespace and to avoid variable name clashes there. Note that m is declared with an initial value of null and the value of m is set within the init() method. This practice makes the macro work better if the story is restarted without refreshing the page.

    handler: function(place, macroName, params, parser) {
      if(params.length > 0) {
        this.m = params[0];
      }
      new Wikifier(place, this.m);
    },

This code checks the length of the params array. If there is something in the params array then the first parameter is saved into this.m. In all cases the contents of this.m are printed.

Once you have added this macro to your story then try adding the following tweecode to a passage in your story:

Initial state: <<recall>>
Store John: <<recall John>>
Store Ben: <<recall Ben>>
What is stored?: <<recall>>

Using parameters and variables in Twine macros is a great way to increase the power of the macro. Storing variables as properties inside the macro object avoids any name clashes with other macros.

How to Create Custom Macros in Twine

This post is a technical article for the Twine hypertext authoring system. I will assume a passing knowledge of Twine/Tweecode and an intermediate knowledge of Javascript. This tutorial applies to version 1.3.5 of Twine - and even further still I assume the latest betas.

There is a bug in the current v1.3.5 Sugarcane and Jonah story formats; custom macros will not work during the display of the "Start" passage. The Responsive story format does not have this problem.

I'll start with a simple macro example then explain it line by line. Put this code into it's own passage. The passage title can be anything. Give the passage the tag "script"

try {
  version.extensions['macrodemoMacro'] = { 
    major:1, minor:0, revision:0 
  };
  macros['macrodemo'] = {
    handler: function(place, macroName, params, parser) {
      new Wikifier(place, "Hello World!");
    },
    init: function() { },
  };
} catch(e) {
  throwError(place,"macrodemo Setup Error: "+e.message); 
}

Let's go through the code a piece at a time (not necessarily in written order).

try {
  ...
} catch(e) {
  throwError(place,"macrodemo Setup Error: "+e.message); 
}

This code sets up basic Javascript exception handling to let you know via a popup dialog when there is a problem in the macro code. Custom macros are inserted into the page at runtime so they can be difficult to debug. This exception handler makes things a bit easier. Technically this is optional, but trust me, it's worth adding. Just change the "macrodemo" text to the name of your macro so you can tell multiple custom macros apart.

  version.extensions['macrodemoMacro'] = { 
    major:1, minor:0, revision:0 
  };

This statement registers the macro with an extensions array. This is totally optional and appears to currently have no effect. If you are making a macro for re-use in many stories then it's a good idea to store version information so why not do it here. Maybe one day it'll be useful. I've taken the macro name and appended "Macro" just to be consistent with the way Twine's in built macros are registered.

  macros['macrodemo'] = {
  ...
  };

This creates the javascript object that holds the custom macro. The macro name in this case is "macrodemo" and you should change this to suit. The title of a macro should not contain spaces, double quotes or any characters that might confuse twine. There are two required functions and you can also add any other macro related variables inside the object.

    init: function() { },

This function is called when Twine is setting up the macro object when the story is started. This is where you should also initialise any variables because init() is called whenever the story is restarted. In many cases an empty function (as above) works just fine. There is no guarantee which order init() functions will be called, except that generally the inbuilt macros have their init() method called first.

    handler: function(place, macroName, params, parser) {
      new Wikifier(place, "Hello World!");
    },

This is the actual code that is executed when your macro is called. A macro is passed four parameters, the most important of which are "place" (an HTMLContainer where text is currently being output to) and "params" (any parameters passed to the macro). Parameters are split into an array on space characters except within "double quotes". The macroName parameter is self-explanatory. The parser gives a reference to the current Tiddlywiki parser object - which is useful only for some advanced cases; e.g. if you were writing a macro that has a corresponding end macro: see the inbuilt if, else and endif macros for an example.

The example code here shows how to do simple text output which is added in place of the macro call. Most Twine macros will want to do something similar to this.

Once the macro is in place then somewhere in your Twine story go:

Custom macro: <<macrodemo>> 

Rebuild the story and you should see Hello World! Congratulations you have written your first macro.

BUG: Backslash characters do not encode / decode correctly from the passage store. Use a workaround such as: String.fromCharCode(92).

TIP: Since the latest betas support multiple source files via StoryIncludes, I like to put macros into separate text (.twee) files just to make organisation and reuse easier.

Macros are a powerful way of adding functionality to your Twine stories. The full power of Javascript is available to you. If you make a good macro then please share.

2012-11-26

Arduino LCD: Defuse

This games is about finding a bomb in a 100 x 100 x 100 cube. That's 1 million possibilities. To help out the player is given a mysterious bomb detector. There is 200 seconds (20 turns) to find the bomb. Each turn the player gives coordinates and the scanner returns a new reading.

Code: http://eturnerx.com/files/arduino/014_defuse_eturnerx_arduino_lcd.html

This time I made some quite big changes to the game. I cut some of the flavour text for illegal moves. For example, if you input numbers too large or small then you'd accidentally step outside the building and fall to your death. Also, the original game uses a fixed algorithm for building the scanner reading. Once you know this algorithm them you can theoretically win in one turn. Instead I made the scanner algorithm change every game. This gives much more replay than the original. It is still very easy to win though and 20 turns is perhaps too many. In my first attempt I won in 8 turns and that included making many errors and inefficient plays.

HINT1: The scanner does not give a pythagorean distance, but it is a strength reading.

HINT2: Get each digit of the scanner to a 9

SPOILER: Each scanner digit is the nine minus the difference between the bomb's position and the scanned position for that digit. The order of the digits is intentionally mixed up. Work digit by digit. Go with "9 minus the most common digit" as your first guess. Once you've located the coordinate digit on the scanner then you can test for value at the same time you locate the next coordinate digit.

Checkout the other games I have converted.

2012-11-21

Arduino LCD: Game Conversion Recap

I have completed converting seven old text based games for the Freetronics 16x2 LCD Arduino Shield. I choose this era of gaming because it was perfect for the LCD Shield and to pay my dues. As a child, I learnt to program by copying these types of games from books and modifying them. It's almost duty to give a new life to these things that helped form me. I got better and faster at making such conversions and learned some good lessons along the way.

A main loop controlled by a switch() statement is a good way to organise a program. They allow extensibility and focus. I already knew this from my other programming experience and it was no different here.

Arduino's have limited heap memory of about 1Kb. You get no warning that the heap is exhausted, instead variables end up with weird values and you won't know why. Text strings use up heap memory too. In a few games I needed to used PROGMEM to get around this limitation.

Showing a routine message on a delay is better than making the user click through them. The earlier games require more clicking and the later games just felt better because they were less "clicky". Of course non-routine messages should require a click.

It's easy to flash the backlight, but it's not always a good idea because it can throw a user's comprehension of text out. Save it for the really important stuff only.

Keep videos short. Everybody loves videos and code, but they won't watch an epic. In later conversions I aimed for a minute and treated it more like a teaser than a play through. Youtube analytics shows this approach seems to be paying off when it comes to audience retention. My skills with Windows Live Moviemaker also increased; it's perfectly fine for this type of work and much cheaper than the pro-packages I have at my workplace.

I think that today's gamers expect more of a challenge. Or maybe that's because gamers are much older than the 1970s. I made Hunt the Wumpus, Acey Deucey, Mugwump and Defuse more difficult than the originals while trying to preserve the original spirit of the game.

It did take some thinking to fit UI onto the 16x2 char screens. Many games had a lot of text and status to show and it became a matter of focusing on the key variables that drive the game. Text lines often needed rewording and this was done to preserve as much flavour as possible. A few of the games (Wumpus, Highnoon, Camel)use a side scrolling menu.

The list of games are:

I enjoyed doing this series but it's now time to move onto other Arduino related projects. I may continue to do old game conversions into HTML using Twine as a break from my other priorities. Keep watching the Games Conversions label on my blog. Thanks for watching.

2012-11-20

Design Demons: The Pragmatist Demon

An earlier post gave an overview of the design demons: Creative, Critic and Pragmatist. This post takes a closer look at the Pragmatist Demon. A designer should develop ability in each of the each of their demons so that the overall team is stronger.

The Pragmatist demon ensures that things gets done. The Pragmatist can be overly economical and un-ambitious in the quest to get things completed. When the Critic Demon is insisting on quality and the Creative demon is insisting on novelty, an overly strong pragmatist can overrule these to complete a solution that is too watered down. The Critic demon is most useful at the beginning of a project (feasibility) and at near the end (deadline crunch). The Pragmatist demon will stifle good ideas from the Creative demon if the Pragmatist is too loud during the concepting phase. The Pragmatist demon's favourite word is: trade-off.

The problem with trade-offs is that the value of a project can be deleteriously compromised if the novelty or quality is watered down.

The underdeveloped Pragmatist demon is unable to set and meet deadlines. The underdeveloped Pragmatist will allow the Creative demon too long to discover the perfect idea and allow the Critic demon to continually nitpick at problems in the design. A person with a weak Pragmatist demon may be full of good ideas and even have some projects started - but little is actually finished.

The strength of the Pragmatist demon can be improved through practice. Set clear constraints (budget, materials, deadlines) for projects and stick to them. Completing work is the life-force of this demon. Any study into process, workflow and project management will permanently strengthen this demon. Writing proposals and problem solving in constrained situations are the Pragmatic demon's gym workout.

The noisy pragmatist will unnecessarily hurry the Creative and Critic demons into doing substandard work. The noisy Pragmatist will discourage the Creative demon by saying the ideas are impractical. By prematurely constraining the Creative demons then concepts might be unnecessary weak. The noisy Pragmatist might overrule the quality decisions of the Critic and this could ruin the polish of the project. However, a noisy pragmatist that gets work out the door is probably the least worst noisy demon because getting stuff done matters most.

A noisy Pragmatist demon can be taught to speak only in turn. Force yourself to use a standard process for projects and do not deviate from the standard process without permission from a mentor. Allow the Creative and Critic demons space to speak before applying "practical" constraints.

A weak Pragmatist demon is best trained through the successful completion of many projects. One way to do this by setting constrained projects (time, budget, other) that must have an output. This will improve the Pragmatist's ability to estimate feasibility going into a project and the constraints will force the Pragmatist to balance priorities in the later stages.

A strong Pragmatist demon is important for a designer to select good projects and complete them on time and in budget. Working to improve the Critic demon will give long term benefit to the designer because completed projects are better than incomplete projects.

2012-11-18

Arduino LCD: Nicomachus

This is a game that is a simple "guess your number" game based on an algorithm published in 90AD. Think of a number between 1 and 100 then answer three questions about it. The original BASIC game is by David Ahl.

Code: http://eturnerx.com/files/arduino/013_nicomachus_eturnerx_arduino_lcd.html

This was a pretty quick conversion. I cut much of the flavour text - including a taunt to recheck your arithmetic if you disagreed with Nicomachus' answer. Having said that, I was surprised at how often people would get a remainder wrong during testing. Maybe the taunt should've stayed. If you'd like to play a more faithful conversion then try my online playable version of Nicomachus.

Checkout the other games I have converted.

2012-11-11

Arduino LCD: Camel

This is a game that is kinda like a cross between Oregon Trail and Highnoon (arduino, html). Make your way 200 hundred miles across a desert without dying in deliciously anachronistic ways.

Code: http://eturnerx.com/files/arduino/012_camel_eturnerx_arduino_lcd.html

I had to alter the text to suit the smaller screen, but did try to preserve the tone and flavour. There are some minor differences to the original game. I used the PROGMEM technique used in my Highnoon conversion to fit all the text into memory. See my Camel Conversion for Twine writeup for more details on the game logic changes and information about optimal strategy.

Checkout the other games I have converted
I have also converted an online playable version of Camel.