Global

Members

antState :boolean

A global boolean storing the current ant state.
Type:
  • boolean
Source:

antx :number

A global variable storing the ant's x position.
Type:
  • number
Source:

anty :number

A global variable storing the ant's y position.
Type:
  • number
Source:

bearing :number

A global variable storing the direction that the ant is facing. Can take the value of up, right, down or left.
Type:
  • number
Source:

(constant) down :number

A global constant that denotes one of the four possible ant directions in this case it is the downwards direction. Have a look at bearing
Type:
  • number
Source:

grid :Array.<Array.<boolean>>

The grid variable stores the state of the world that the turmite is moving through in the global namespace.
Type:
  • Array.<Array.<boolean>>
Source:

(constant) left :number

A global constant that denotes one of the four possible ant directions in this case it is the left direction. Have a look at bearing
Type:
  • number
Source:
A global constant that denotes one of the four possible ant directions in this case it is the right direction. Have a look at bearing
Type:
  • number
Source:

scale :number

Scale is a global variable that determines how many pixels will take up one grid square.
Type:
  • number
Source:

(constant) up :number

A global constant that denotes one of the four possible ant directions in this case it is the upwards direction. Have a look at bearing
Type:
  • number
Source:

Methods

draw()

p5.js draw function. Draws the ant and calculates it's next movement.
Source:

moveForward()

Change the ants position depending on which direction it is facing.
Source:

setup()

p5.js setup function. Creates a html canvas and adds a white background. Set all values in the grid to 1. Initialise the antx, anty and bearing variables. Set the antState to false.
Source:

turnLeft()

Turn left changing the ants bearing.
Source:

turnRight()

Turn right changing the ants bearing.
Source:

Documentation generated by JSDoc 3.6.3 on Sat Jun 11 2022 20:49:50 GMT+0100 (BST)