@frankieseh/toy_robot
v0.0.2
Published
A production-ready CLI application that simulates a toy robot moving on a 5x5 table
Readme
Toy Robot Simulator
A CLI application that simulates a toy robot moving on a configurable grid table, written in TypeScript with strict typing, layered architecture, and high test coverage.
Features
- File and interactive stdin command processing
- Commands:
PLACE,MOVE,LEFT,RIGHT,REPORT,HELP - Boundary-safe movement on a configurable table (Default: 5x5)
- Clean layering across domain, application, and infrastructure
- Usable as both CLI and importable library API
Requirements
- Node.js
24.0.0or newer - npm
Installation
Install globally
npm install -g @frankieseh/toy_robotOr use with npx (no installation required)
npx @frankieseh/toy_robotDevelopment setup
git clone https://github.com/frankieseh/toy_robot.git
cd toy_robot
npm install
npm run buildUsage
Run from file
toy_robot examples/example1.txtInteractive mode
toy_robotThen enter commands line-by-line. REPORT outputs state and closes the interactive session.
Command Reference
PLACE X,Y,F— place robot on table (must be first valid command)MOVE— move one step forwardLEFT— rotate 90° counterclockwiseRIGHT— rotate 90° clockwiseREPORT— printX,Y,DIRECTIONHELP— print command help
Example
Input:
PLACE 1,2,EAST
MOVE
MOVE
LEFT
MOVE
REPORTOutput:
3,3,NORTHLibrary Usage
Install as a dependency:
npm install @frankieseh/toy_robotImport and use:
import { Simulator, Table } from '@frankieseh/toy_robot';
const simulator = new Simulator(new Table(5, 5));
simulator.executeCommand('PLACE 0,0,NORTH');
simulator.executeCommand('MOVE');
const output = simulator.executeCommand('REPORT');
console.log(output.message); // 0,1,NORTHLicense
MIT (See LICENSE.md) Copyright (c) 2026 Frankie Sehrawat
