Toy Robot Simulator

version: 0.0.1

The Ruby gem let the toy robot move a table painlessly, easily, and most importantly, it does not fall from the table

  • Full gem documentation (version 0.0.1) # Installation gem install toy-robot-simulator ruby gem "toy-robot-simulator", "~> 0.0.1" bundle install # Usage ## ToyRobotController The main component of this gem is which instantiate Robot, Table and process commands. In order to use this controller you need to do the following:

1. Include the ToyRobotController

require  'toy_robot_controller'

2. Initialize the controller

ToyRobotController.init(commands: Array, table_size : int)

There is also a CommandLoader module available which can read the test data from file and return commands array which can be passed into init of our controller

examples:

ToyRobotController.init(['PLACE 0,0,NORTH', 'MOVE'])

3. Execute the commands

ToyRobotController.execute_commands

4. Report

ToyRobotController.report

CommandSetLoader

require  'helpers/command_set_loader'
include CommandSetLoader
commands = CommandSetLoader.read_commands('./test_data/test1.txt')

We can use this helper method to generate the array of commands which can be used as commands with ToyRobotController

ToyRobotController.init(commands)

Things to considered

init method of ToyRobotController expects array of commands where all the commands should be type of string

If you are using the CommandSetLoader, make sure that your file has each command on a new line such as:

PLACE 0,0,NORTH
MOVE
REPORT

TODO

  • Add configuration option
    • Ability to change PLACE command sequence such as
      • X,Y, NORTH PLACE
      • NORTH X Y PLACE
  • CommandSetLoader is reading file locally, would be a good idea to add the option to read the file remotely
  • Add obstructions on the table
  • Non square table