Authoring (How to write)

You can write your own Minds and Worlds. They are hosted on this server.

You need to register and login to write your own Minds and Worlds.





JavaScript

All Worlds and Minds are written in JavaScript. They all run on the client side.

All Worlds and Minds can be written in the browser. No install is needed to write them or run them.

JavaScript is an important programming language. Some surveys even rank it as the most important programming language in the world. It is a valuable skill for a tech career.

Some useful JavaScript links:






APIs

Each World runs using a particular API. The API typically provides graphics JS libraries plus Ancient Brain libraries. Each Mind uses the API of its World.

New APIs will be added in the future. (For example, ones based on new graphics libraries.) All old APIs will be kept, so that runs always work.

The home page for each World links to the API it uses. Authors should examine the API page to see how to write for it.

As far as possible, APIs are designed so that most parts are optional. Authors can omit parts and, as far as possible, the program will still run.

See List of APIs currently installed.




Edit in browser

To edit code in the browser, we use the Ace editor. This does JavaScript syntax highlighting and syntax checking.

Useful links:

Some useful keyboard shortcuts:

  • Ctrl-F - Find.
  • Ctrl-H - Find and replace.

  • Ctrl-D - Delete line
  • Ctrl-Z - Undo.
  • Ctrl-comma - Settings. Can change font and theme.

  • Click on bracket - Highlight matching bracket.
  • Ctrl-P - Jump to matching bracket.


Run from editor

You can run direct from the editor using the "Run" button. But note it runs the saved version, not the text currently in the editor if not saved.


Browser - Force reload

Developing in a browser can conflict with the fact that the browser caches files to speed up browsing.

This site uses a "cache buster" to effectively disable caching for World and Mind JS. But it does not disable caching for other user-submitted files (World and user images, and uploads, which may include more JS).

Sometimes, if you are working with these other files, you may need to force the browser to go back to the server for the latest copy, rather than displaying the cached version.


Outputting debug information

You can output debug information to:
  1. The JavaScript console (in the run window). You can use console.log();
  2. The user_span status areas in the run window. ("View Source" on a run to see these.)
  3. Creating new divs in the window. See the following.


Outputting arbitrary amounts of data

You can output arbitrary amounts of data. Let us say you are running an AI learning experiment and want to output the Mind's data structure after a long Machine Learning run. Do this:
  1. Create a new div using document.createElement('div') and append it to the page.
  2. Use CSS to put it in the foreground and give it a scrollbar.
  3. Output your data to the div.
A plan for the future is to give you a personal file system you can output to.
  
 
  

Object Oriented programming in JavaScript

In setting up classes and doing Object Oriented programming in JavaScript, we follow this guide: See examples here:




Obfuscate your JavaScript

The nature of JavaScript is that the source code is visible, so this site supports built-in obfuscation for those who want to hide their code.

If you want to make it difficult for people to copy/modify your code, you can save the JS in an obfuscated (also minimised) form. The obfuscated JS is the version visible online, and the version that runs when you click Run. The plain text JS is saved on our server. When you Edit, the plain text version is always loaded. Only the owner can see this.

Obfuscation is optional and is off by default. When you Edit, you will see an option like the following to save the public JS in an obfuscated form or in plain text:

Trying to de-obfuscate someone's obfuscated JS is against our terms of use.




Include another JS file

You can include another JS file in your code. This can be a local (on our server) or remote JS file.

Inside newRun() insert a new script element into the page:

   var s = document.createElement("script");
   s.src = SOMEURL;                           // local or remote URL
   s.onload = function() { SOMECODE };        // function to be called when JS is loaded
   document.head.appendChild(s);  

Note the loading of the JS is asynchronous, so there may be a short delay before the JS is available for use. Your code may need to check if the JS is ready or not. See some example code in calling another Mind.


Multiple JS files

To break up your code into multiple JS files, upload the extra JS files into your "Uploads" section. You can edit them online with the "Edit" button on the Uploads page.

Your main World or Mind JS file can then include those other JS files as described above.


Worlds and Minds do not have to be on this site

Following on from the above, Worlds and Minds do not have to be on this site. You can develop Worlds and Minds on your own site, with your own development tools. So long as they are JS at some URL. You can then upload a stub World or Mind to this site which drags in the JS from your site at run-time. This relates to The AI model behind this site.

The background is a program, showing the JavaScript graphics used on this site.
 
Font:

© Ancient Brain Ltd. All rights reserved.

Ancient Brain ™ is a trademark of Ancient Brain Ltd.

Beta      Bug bounty      Contact      Stats      The name      Terms and conditions