Skip to content

hadibadjian/locobot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Locobot

A simulation of a toy robot moving on a square tabletop of 5x5 dimension.

Usage

Configure the robot with appropriate input parser:

  • JSON Parser
  Locobot::Config.input_parser = Locobot::Parser::JSONParser.new
  Locobot::Config.command_separator = '->'
  • File Parser
  Locobot::Config.input_parser = Locobot::Parser::FileParser.new

Define the robot input commands, respectively:

  • JSON input
  input = "{ \"commands\": \"PLACE 5, 5, NORTH -> MOVE -> LEFT -> RIGHT -> REPORT\" }"
  • File input
  input = '/file/path/file_parser_sample_1.txt'

Feed the input and run the robot!

  Locobot::Config.input_parser.read input
  Locobot::Core.new.run

Versions

v0.1.0

  • No obstructions on the table
  • The robot is free to roam around on the table
  • The robot should not fall to destruction.
    • ignore any command that would result in the fall
    • continue with the next valid command
  • The robot should receive an initial placement position
    • (0, 0) is the south west corner
  • The robot should receive valid movement commands.
    • valid commands are:
      • PLACE(x, y, face): Position the robot at point (x, y), facing towards face.
      • MOVE: Move the robot one unit forward. (Ignored if robot is not on the tabletop).
      • LEFT: Rotate robot 90 degrees to the left. (Ignored if robot is not on the tabletop).
      • RIGHT: Rotate robot 90 degrees to the right. (Ignored if robot is not on the tabletop).
      • REPORT: Report current position of the robot. (Ignored if robot is not on the tabletop).
    • any commands before the initial PLACE must be ignored
    • multiple PLACE commands is valid
  • The robot should read commands and execute them sequentially

About

A simulation of a toy robot moving on a square tabletop of 5x5 dimension.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors