The Line Agency project is a single agent algorithm that determines the scalable value of angles for each canvas boundary (i.e. the walls of the canvas). To determine the angle, trigonometry is applied to calculate the agent's trajectory (i.e. xPos += cos(radians(angle)) * stepSize;). In conjunction to this, a function with conditional statements are also used. Within those statements are the set trajectory which are triggered once the agent has landed on the appropriate angle.

Link to Full Codes

                        let randomAngle = floor(random(0, 180));
    
                        if (_x > width) {
                            return randomAngle + 90;
                        }

                        if (_x < 0) {
                            return randomAngle + 270;
                        }

                        if (_y > height) {
                            return randomAngle + 180;
                        }

                        if (_y < 0) {
                            return randomAngle;
                        }