How to code with P5

How to code JavaScript on Ancient Brain with the "P5" library.
To get started with P5, do the following Starter Tutorial. This does not assume you have ever written a program.
P5 Starter Tutorial
This course shows you how to make many different modifications to this basic "Starter World":
One Cube World (P5)
458 runs ♦ 0 likes
By Starter user  
Created: 10 Nov 2018
Modified: 14 Nov 2019
Simple starter World (P5 version). No camera control. So cube rotates to show 3D.
How to write JS on Ancient Brain
Explains how to code in JavaScript (JS) on Ancient Brain. To create a World, you need to register and log in. Click a World name to go to its "home page" where you can take actions. Edit code in the browser. Run direct from the editor. Explains ways to output data. Explains how to include another JS file.

How to write a World
To code a World, make a blank new one, or "clone" an existing World and change it. Worlds are written for a specific "API". Explains World screenshots. Explains how to upload support files and use them. Explains how to do keyboard, mouse and touch interaction.
How to write a World that uses no Mind
Step-by-step guide.
How to write a World that uses a Mind
Step-by-step guide.

How to write a Mind
Step-by-step guide. Explains how Minds can call other Minds. This is the AI model behind Ancient Brain.
We have two courses on Introduction to Programming, both using JavaScript, both using the P5 library.

  • Intro to Programming for kids.
  • Intro to Programming for anyone.

This course is a very gentle introduction to programming, with kid-friendly language. This does not assume you have ever written a program.
Intro to Programming for kids
This course will let you modify (though not build from scratch) Worlds like the following:
Trampoline World
404 runs ♦ 0 likes
By Alex Murphy  
Created: 9 Apr 2019
Modified: 19 May 2019
Learn how to upload images & music
World View (Example)
279 runs ♦ 0 likes
By Alex Murphy  
Created: 2 May 2019
Modified: 18 May 2019
World View Example
Bouncy Balls
329 runs ♦ 0 likes
By Alex Murphy  
Created: 25 Mar 2019
Modified: 11 Apr 2019
bouncy balls
jump/duck/hide
325 runs ♦ 0 likes
By Alex Murphy  
Created: 4 Apr 2019
Modified: 18 May 2019
if/else lesson
This is a more systematic Introduction to Programming course, for anyone, using JavaScript and P5. This does not assume you have ever written a program.
Intro to Programming for anyone
When you are finished this course, you will be able to make from scratch Worlds like the following:
Tutorial 7.8 variant
182 runs ♦ 0 likes
By "Coding Train" p...  
Created: 6 Sep 2018
Modified: 11 Sep 2018
Tutorial 7.8 with music and other uploaded images, including from other users. Click on the images.
Tutorial 7.3
90 runs ♦ 0 likes
By "Coding Train" p...  
Created: 5 Sep 2018
Modified: 5 Sep 2018
Arrays of Objects
Tutorial 2.1
212 runs ♦ 0 likes
By "Coding Train" p...  
Created: 4 Sep 2018
Modified: 4 Sep 2018
Variables in p5.js (mouseX, mouseY)
This is a followon to the "Intro to Programming for anyone" course above. This is a course in 3D graphics programming in JavaScript, using P5.
3D graphics course
When you are finished this course, you will be able to make Worlds like the following:
Tutorial 18.7
261 runs ♦ 0 likes
By "Coding Train" p...  
Created: 9 Sep 2018
Modified: 11 Sep 2018
Tutorial 18.7 with full canvas, resized model, sound. Texture on box is image from another user.
Tutorial 18.5
27 runs ♦ 0 likes
By "Coding Train" p...  
Created: 9 Sep 2018
Modified: 2 Jun 2019
Camera and Perspective
Not a full course in AI (Artificial Intelligence) but a series of online AI programming exercises, at the Dublin City University site. This includes exercise notes with problems for students to solve. All code is on Ancient Brain, in JavaScript, using P5.
AI programming exercises
Here are some of the AI Worlds on this course:
A star
561 runs ♦ 1 like
By "Coding Train" p...  
Created: 1 May 2019
Modified: 16 May 2019
Port of "05_astar"
GA (TSP)
243 runs ♦ 0 likes
By "Coding Train" p...  
Created: 24 Jun 2019
Modified: 25 Jun 2019
Port of GA (TSP) by "Coding Train" project
Breadth-first se...
519 runs ♦ 0 likes
By "Coding Train" p...  
Created: 30 Apr 2019
Modified: 1 May 2019
Port of "02_bfs_oop_fdg"
Character recogn...
284 runs ♦ 0 likes
By "Coding Train" p...  
Created: 5 Jul 2019
Modified: 7 Jul 2019
Port of Character recognition neural network from the Coding Train
GA (Finnegans Wake)
354 runs ♦ 0 likes
By "Coding Train" p...  
Created: 2 May 2019
Modified: 12 Jun 2019
Port of "NOC_9_01_GA_Shakespeare_simplified"
JavaScript
Links to full JavaScript and jQuery reference.

AB object
Ancient Brain runs have an "AB" object defined, which provides lots of built-in functionality and customisability on every run. This is a full reference for the data and methods of the AB object.
AB World and Mind definitions
You define Worlds and Minds by defining methods for AB.world and AB.mind. Then Minds can run in Worlds. This explains the syntax.
AB legacy code
Explains some legacy code you might see in some people's Worlds. One of the core principles of Ancient Brain is that old Worlds will run forever.
Types of runs
Explains how to run "logged in". Explains how to send extra information to runs.

APIs
A summary page of all the APIs. Compares them by libraries used and functionality.

Resources
Some useful links for how to get resources online, such as textures, 3D models and sound effects.
Ace editor
Links to the official Ace editor docs, and quick reference. Explains the "Intelligent code help".

P5 reference
Links to the official P5 docs.