話をゼロから創作するというのは大変なことです。頭の中で世界を描き、それに合わせてキャラクターを動かしていきます。慣れると想像のキャラクターたちが自分で勝手に動き出すかも知れません。 そんなストーリーをプログラマブルに作れるのがstory-graphです。

story-graphの使い方

サンプルを実行します。実行するたびに内容が変わっているのが分かります。

$ node example.js 
The whisper passes through the sunlight. The whisper is illuminated by the sunlight. The ice joins with the sunlight for a moment. The ice does a whirling dance with the sunlight. The whisper passes through the sunlight. The whisper is illuminated by the sunlight. 
$ node example.js 
The sunlight joins with the shadow for a moment. The sunlight does a whirling dance with the shadow. A bluejay approaches the shadow. A bluejay and the shadow pass eachother quietly. The river discovers the sunlight dancing with the shadow. The river observes the patterns of the sunlight dancing with the shadow. The river dwells in the stillness of life . 

コードの一部です。オブジェクトを作って、その属性を設定しながらお話の設計を行います。

$ cat example.js 
var World = require('./src/world.js');
var Thing = require('./src/thing.js');
var c = require('./src/constants.js');

var life = entity.extend('life');
var animal = life.extend('animal');
  :
var spirit = entity.extend('spirit');

var bumbling = extendType('bumbling');
  :
var inflowing = extendType('inflowing');

var world = new World();

var river = new Thing({
	type: curving(complex(outpouring(spirit))),
	name: 'the river'
})
  :
world.addRule({
  cause:{
    type: [inflowing(spirit), c.encounter, outpouring(spirit)],
    value: [c.source, 'joins with', c.target, 'for a moment']
  },
  consequent: {
    type: [],
    value: [c.source, 'does a whirling dance with', c.target]
  },
  isDirectional: false,
  consequentThing: {
    type: complex(connection),
    name: 'dancing with',
    members: [c.source, c.target],
    lifeTime: 2,
    initialize: function(storyEvent, world){
    	this.name = this.members[0].name+' '+this.name+' '+this.members[1].name;
    }
  }
})
  :
console.log(world.makeStory(3));

ルールを追加していくことで分岐になったり、ストーリーがより複雑になっていきます。英語のみ対応していますが、思わぬ名作が生まれる可能性もあるのではないでしょうか。

story-graphはnode/JavaScript製のオープンソース・ソフトウェア(MIT License)です。

incrediblesound/story-graph