How to code with P5

How to code JavaScript on Ancient Brain with the "P5" library.
To get started with Ancient Brain using P5, do the following Starter Tutorial. This does not assume you have ever written a program.
Starter Tutorial (P5)
This course shows you how to make many different modifications to this basic "Starter World":
One Cube World (P5)
1396 runs ♦ 1 like
By Starter user  
Created: 10 Nov 2018
Modified: 21 Apr 2021
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 various online courses where you can learn to code in JavaScript on Ancient Brain. They are listed in the "Learn" menu. Pick a course and do it.

We will now explain the courses we have.

This is a proper Introduction to Programming course, with videos, using JavaScript and P5. This does not assume you have ever written a program.
Introduction to Programming
And part two:
Introduction to Programming: Part Two
When you are finished this course, you will be able to make from scratch Worlds like the following:
Tutorial 7.3
202 runs ♦ 0 likes
By "Coding Train" p...  
Created: 5 Sep 2018
Modified: 5 Sep 2018
Arrays of Objects
Tutorial 7.8 variant
335 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 2.1
489 runs ♦ 1 like
By "Coding Train" p...  
Created: 4 Sep 2018
Modified: 4 Sep 2018
Variables in p5.js (mouseX, mouseY)
This is a course in JavaScript 3D graphics ("WebGL") programming, using P5.
WebGL course
When you are finished this course, you will be able to make Worlds like the following:
Tutorial 18.5
84 runs ♦ 0 likes
By "Coding Train" p...  
Created: 9 Sep 2018
Modified: 2 Jun 2019
Camera and Perspective
Tutorial 18.7
377 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.
This is an alternative introduction to programming, with kid-friendly language. This does not assume you have ever written a program.
Alternative JavaScript course for kids
This course will let you modify (though not build from scratch) Worlds like the following:
jump/duck/hide
359 runs ♦ 0 likes
By Alex Murphy  
Created: 4 Apr 2019
Modified: 18 May 2019
if/else lesson
Bouncy Balls
367 runs ♦ 0 likes
By Alex Murphy  
Created: 25 Mar 2019
Modified: 11 Apr 2019
bouncy balls
World View (Example)
336 runs ♦ 0 likes
By Alex Murphy  
Created: 2 May 2019
Modified: 18 May 2019
World View Example
Trampoline World
449 runs ♦ 0 likes
By Alex Murphy  
Created: 9 Apr 2019
Modified: 19 May 2019
Learn how to upload images & music
This AI course does not have a full set of notes explaining AI theory. You will need to get that somewhere else.

Rather this is a series of online AI programming exercises, with problems for students to solve. These exercises could be used to accompany a full AI theory course (and indeed have been used for that). All code is in JavaScript using P5.

AI exercises
Here are some of the AI Worlds on this course:
GA (Finnegans Wake)
813 runs ♦ 0 likes
By "Coding Train" p...  
Created: 2 May 2019
Modified: 15 Dec 2019
Genetic Algorithm to write the first line of Finnegans Wake.
Character recogn...
1557 runs ♦ 0 likes
By "Coding Train" p...  
Created: 5 Jul 2019
Modified: 2 Jul 2021
Neural network to do character recognition from image database and from handwriting in real-time.
Breadth-first se...
1840 runs ♦ 0 likes
By "Coding Train" p...  
Created: 30 Apr 2019
Modified: 15 Dec 2019
Breadth-first search with a Force-directed graph.
A star
3036 runs ♦ 1 like
By "Coding Train" p...  
Created: 1 May 2019
Modified: 21 Oct 2022
"A Star" algorithm to find shortest path through maze.
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.