Toy Robot simulator with two modes:
- CLI simulator (
npm start) - Browser game for GitHub Pages (
npm run web:start)
The browser experience is an interactive game powered by the same command engine and rules as the CLI.
Toy Robot moves on a tabletop grid with no obstacles.
- Grid coordinates are
0..5for both X and Y (6x6 board). - Origin
(0,0)is the south-west corner. - Invalid/failed commands do not stop the simulation.
Commands:
PLACE X,Y,Fplaces the robot atX,YfacingF.MOVEmoves one unit forward.LEFTrotates 90 degrees anti-clockwise.RIGHTrotates 90 degrees clockwise.REPORToutputsX,Y,F.
Facing direction F must be one of:
NORTHEASTSOUTHWEST
- Commands are case-sensitive and must be uppercase.
- Leading/trailing spaces are allowed (for example
REPORT). PLACEparameters cannot contain empty values (for examplePLACE ,,NORTHfails).- Any move that would cause a fall fails and keeps the same state.
- Commands are ignored until the first valid
PLACE.
The first valid command must be PLACE.
After that, any sequence of commands is allowed, including another PLACE.
Input:
PLACE 0,0,NORTH
MOVE
REPORT
Output:
0,1,NORTH
Input:
PLACE 0,0,NORTH
LEFT
REPORT
Output:
0,0,WEST
Input:
PLACE 1,2,EAST
MOVE
MOVE
LEFT
MOVE
REPORT
Output:
3,3,NORTH
Install dependencies:
npm installRun tests:
npm testStart CLI simulator:
npm startExample input:
PLACE 0,0,NORTH
MOVE
REPORT
Exit with Ctrl + C (Windows/Linux) or Cmd + C (macOS).
Build and serve the static game locally:
npm run web:startThen open:
Features:
- Visual 6x6 board with robot direction icon
- Demo preset buttons for Example A/B/C
- Single command input
- Multiline script mode (Step / Run All)
- Script progress preview with active-line highlight during stepping
- Latest command status banner (
SUCCESS/FAILED) - Command log with success/fail messages
For a clean live demo:
- Open the app and show the
Board (0..5)grid. - Click
Example CinDemo Presets. - Click
Steprepeatedly and point out the highlighted active script line. - Show
Current State,Latest Status, andCommand Logupdating together. - Click
Run AllforExample Ato quickly show expectedREPORToutput.
Deployment is automated by GitHub Actions via .github/workflows/deploy-pages.yml.
- Push to
maintriggers tests + static build + deployment. - Expected public URL:
If your repo name or owner changes, update the URL accordingly.
Install Playwright browsers once:
npx playwright installRun smoke test:
npm run test:e2e