GithubHelp home page GithubHelp logo

toy-robot's Introduction

Toy Robot

Build Status

The application is a simulation of a toy robot moving on a square tabletop written in Ruby.

Available Commands

Commands Description
PLACE X,Y,F Place the robot on the table at coordinates x,y and facing the direction f. Valid x andy values are between 0-4. Valid facings are WEST, NORTH, EAST, SOUTH. Example Input: 'PLACE 0,0,NORTH'
MOVE Move the robot forward 1 step in the direction it is facing.
LEFT Turn the robot's direction 90 degress to the left. I.e. if the robot is facing NORTH, 1 left turn will turn the robot's direction to WEST.
RIGHT Turn the robot's direction 90 degress to the right. I.e. if the robot is facing NORTH, 1 left turn will turn the robot's direction to EAST.
REPORT Output the current position of the robot. Example Output: 'Output: 0,0,NORTH'

Notes

I've used the command pattern to interpret user input and create Ruby objects representing these commands.

Setup

Clone the repository:

$ git clone [email protected]:yevdyko/toy-robot.git

Change into the directory:

$ cd toy-robot

Install the required dependencies:

$ bundle

Testing

To run the tests:

$ rspec

How to use

$ ruby ./bin/app.rb input_file_path.txt

For instance, you can use the following sample files with inputs:

Example A

$ ruby ./bin/app.rb ./data/sample_input_1.txt

Expected Output:

0,1,NORTH

Example B

$ ruby ./bin/app.rb ./data/sample_input_2.txt

Expected Output:

0,0,WEST

Example C

$ ruby ./bin/app.rb ./data/sample_input_3.txt

Expected Output:

3,3,NORTH

toy-robot's People

Contributors

yevdyko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.