pandres95 / s4n-technical-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drones4Corrientazo

This project contains the module @corrientazo-domicilios/drones, which allows simulating the behaviour of drones flying around the neighbourhood around "El corrientazo domicilios". Spec is here

Setup

Requirements

Due to the nature of recent ES6 features this module has, it requires Node 14.x or above.

Installation

This module needs no dependencies. However, just in case you need to enable development environment, just run:

npm install

Configuration

You can use environment variables to set operational parameters:

Name Type Description
BLOCK_SIZE Number The size of the block the drone is limited to
MAX_ORDERS Number The number of maximum concurrent orders a Drone can manage in a single run

Usage

First, import and define a new Drone

import { Drone } from './lib/drone.js';

const drone = new Drone();

The drone will be initialized at (0, 0) heading towards North.

.executeCommands(commands)

The easiest way to manipulate the drone is by running commands. This method receives an array of Numbers, each one representing a command. The possible commands are:

  1. 0: Move forward.
  2. -1: Rotate to the left.
  3. 1: Rotate to the right.

#move()

Moves the drone one step at a time.

#rotate(position)

Rotates the drone a number of positions. Receives an integer indicating how many rotations the drone should do. Each rotation represents a 90º clockwise (positive integers) or counter-clockwise (negative integers) change.

About


Languages

Language:JavaScript 100.0%