Skip to content

learn-co-students/robotSimulator.js-dc-web-031218

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robot Simulator

alt text

Background

Step 1

The robot factory manufactures robots that have three possible movements:

  • turn right
  • turn left
  • advance

Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of [x, y] coordinates, e.g. [3,8].

Step 2

The factory's test facility needs a program to verify robot movements.

There are a number of different rooms of varying sizes, measured in Robot Units, the distance a robot moves when you instruct it to advance.

The floor of the room is a grid, each square of which measures 1 square RU (Robot Unit).

The rooms are always oriented so that each wall faces east, south, west, and north.

The test algorithm is to place a robot at a coordinate in the room, facing in a particular direction.

The robot then receives a number of instructions, at which point the testing facility verifies the robot's new position, and in which direction it is pointing.

alt text

Step 3

The robot factory's test facility has a simulator which can take a string of letters and feed this into a robot as instructions.

  • The letter-string "RAALAL" means:
    • Turn right
    • Advance twice
    • Turn left
    • Advance once
    • Turn left yet again
  • Say a robot starts at [7, 3] facing north.

Then running this stream of instructions should leave it at [9, 4] facing west.

Tests

To run the specs follow these commands:

learn

View Robot Simulator on Learn.co and start learning to code for free.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published