Make-Believe (R22): Command and Control

umbrella_textThis version mostly focuses on giving access to Make-Believe outside of the browser. There are two components to this: an API and a standalone desktop app. I describe those in a bit more detail below.

The only other significant change in this version is support for text boxes from .xdsl files (see image at right). They are view-only, but you can move them around.


The API is available via node.js. The initial version just exposes the main classes in the core Make-Believe JavaScript files in a node.js module. Using the makeBelieve.js module, it’s now possible to create a Bayesian network, add some nodes and then do an inference. Here’s an example (adapted from the apiTest.js file):

var mb = require("./makeBelieve.js");

var bn = new mb.BN();
var pollutionNode = bn.addNode("Pollution", ["High", "Medium", "Low"],
   {cpt: [.1,.4,.5]});
var cancerNode = bn.addNode("Cancer", ["Absent", "Present"],
   {parents: [pollutionNode], cpt: [.3,.7, .2,.8, .05,.95]});

Note the last line actually requires a custom/temporary console.apilog function for now, as I’m suppressing lots of junky ordinary console.log output. That obviously needs to change.

It also currently requires ‘cheerio’ (essentially, jQuery optimised for node.js). Since I’m not using very much of it, I may try to remove that dependency, which would make the API significantly smaller and more convenient.

Current steps for using the API with the apiTest.js:

  • Install node.js (if don’t have)
  • Grab Make-Believe source files (choose ‘Download ZIP’) and extract somewhere
  • Go to the Make-Believe folder with ‘apiTest.js’
  • (If first time) Run ‘npm install cheerio’
  • Run node apiTest.js

Standalone Desktop App

I also fortuitously came across Electron this week. Actually, I’d encountered it before, but I read something that inspired me to believe porting a HTML5 app to it would be easy. And indeed it is. So here is a first version for Windows:

Extract it, run make-believe.exe and voilĂ .

It should be easy to get it working on other platforms too. Grab a pre-built Electron build from here, extract it, and then copy the core Make-Believe files into resources/app (you need to create the ‘app’ folder in resources). You then need to run ‘electron’ with no arguments.

To be honest, the use cases for the desktop version are pretty limited. Make-Believe is a web app first and foremost, and the web app will always be the most capable version. What’s more, you can put Make-Believe anywhere you want (on your own webserver, for example) and it will just work. If you’ve got Firefox, just running ‘index.html’ from the source files will run just fine. (Chrome has (always had) very crappy support for file: based apps. IE might work, but I still haven’t gotten things working in that generally yet. I’m hoping Edge will catch up by itself.)

As such, I may not update the desktop version very much. Still, getting things going was very easy, so well done to the Electron team. (Of course, since Chromium and node.js are both bundled, the size is quite hefty.)


  • Small improvement to CPTs (state name overflow, fixed width columns)
  • Add support for textboxes
  • Allow textboxes to be moved (initial)
  • API: Fair bit of work to get something working in node.js. Requires ‘npm install cheerio’.
  • API: Created apiTest.js for API examples/testing. Run as ‘node apiTest.js’.

Leave a Reply

Your email address will not be published. Required fields are marked *