Skip to the content.

Testing Bot Example

The Testing Bot code lets you add bots/npcs to a space. Bots can be given specific properties and can be programmed to carry out actions.

Bots can:

Authors

Prerequisites

Usage

  1. Clone this repository using git clone <repo URL>.
  2. Within this directory, run npm install to install or update the script dependencies. (NOTE: You may receive errors regarding node-gyp. This is an OPTIONAL module and you can ignore those errors.)
  3. Run npm run bots -- --help for help.
  4. Run npm run bots, supplying any command-line arguments as desired.

Command Line Arguments

The following command line arguments can be used to define bots or access help:

Each property that takes an array on the command line will apply each element of that array to an individual bot. So, if 3 bots are created with 3 volumes specified, --numBots 3 --volume 1 0.8 0.5, the first bot will have a volume of 1, the second will have a volume of 0.8, and the third will have a volume of 0.5.

If fewer command line arguments for a property are listed than the number of bots created, the first value in the argument will apply to all remaining bots. For instance if 3 bots are created with only two volumes specified: --numBots 3 --volume 1 0.8, the first bot will have a volume of 1, the second will have a volume of 0.8, and the third will have a volume of 1.

## Example The following command line input will create 4 bots:

  1. “0” is blue at (0, 0, 0) and plays a sine wave at 440Hz with a volume of 0.9 with a gain of 0.5
  2. “Johnny5” is yellow at (1, 1, 1) and plays a local file called file2.mp3 at a volume of 0.9 with a gain of 2
  3. “2” is blue at (2, 2, 2) and plays the file at https://someURL.com with a volume of 0.9 and gain of 10
  4. “3” is blue at (3, 3, 3) and does not play audio
npm run bots -- --numBots 4 --audio 440 file2.mp3 "https://someURL.com" "" --volume 0.9 --gain 0.5 2 10 --name # Johnny5 --color #1d05f7 #f7d305 --x 0 1 2 3 --y 0 1 2 3 --z 0 1 2 3

Bot JSON Configuration

If you’d like to configure many bots in a specific way, you can create a bot JSON configuration file and pass that file via the command line using the --configuration argument.

Any configuration properties set via command line will override properties set via JSON.

This example will create two bots:

{
	{
		"x": 42,
		"y": 19,
		"name": "C3PO",
		"audio": "https://c3po.mp3"
	},
	{
		"x": 54,
		"y": 29,
		"name": "R2D2",
		"audio": "https://beeps.mp3"
	}
}

Motion

Bots can be programmed to follow motion steps or move randomly along a line or within a box boundary.

This bot will move back and forth along the x axis between -15 and 15.

"motor": {"type": "RandomBoundedMovement", "x": [-15, 15]}

This bot will move randomly within a box that stretches from -15 to 15 on the x axis and from -15 to 15 on the y axis.

"motor": {"type": "RandomBoundedMovement", "x": [-15, 15], "y": [-15, 15]}

Bot Functions

The npm run bots command uses the integration-test.js script. If you need finer control over the bots, you can write your own script that makes use of the Bot class in bot.js and which manipulates them more specifically. For example, each Bot instance has: