kata-mars-rover
Version, currently master branch1 version
- master branchlatestJun 16, 2019
github.com/allousas/kata-mars-rover
Mars rover kata from https://technologyconversations.com/2014/10/17/java-tutorial-through-katas-mars-rover/
Installation
# Add this to your shard.yml
dependencies:
kata-mars-rover:
github: allousas/kata-mars-rover
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.25.1- License
- MIT
- Author
- Albert Llousas
- Target
kata-mars-roverfrom src/mars-rover.cr
Dependencies
This version declares no dependencies.
README
kata-mars-rover
I chose this one to learn and play a bit with Crystal language.
Since it is done in an earlier version of Crystal (0.25.1), language features could change.
Kata
Develop an api that moves a rover around on a grid.
Rules:
- You are given the initial starting point (x,y) of a rover and the direction (N,S,E,W) it is facing.
- The rover receives a character array of commands.
- Implement commands that move the rover forward/backward (f,b).
- Implement commands that turn the rover left/right (l,r).
- Implement wrapping from one edge of the grid to another. (planets are spheres after all)
- Implement obstacle detection before each move to a new square. If a given sequence of commands encounters an obstacle, the rover moves up to the last possible point and reports the obstacle.
Approach
The solution is a mixed paradigm approach of object oriented programming and functional programming with pure data structures.
Installation & Troubleshooting
crystal -v
Crystal 0.25.1 (2018-06-30)
Install crystal lang following instructions here :
https://crystal-lang.org/docs/installation/on_mac_osx_using_homebrew.html
##Usage
It is an API of rover, take a look on the test to see how it looks.
IDE
Given it is an earlier version of crystal, IDEs as idea are not supporting it well yet. I would recommend using atom.io with crystal packages.
run tests
crystal spec
format code
crystal tool format src/
To improve
- Error handling: Crystal's way to do error handling is by raising and rescuing exceptions without typing methods, could be improved with a using a simple wrapper or a monadic structure
- Mocking libraries: https://github.com/waterlink/mocks.cr is not working with crystal
0.25.1, so it was not possible to mock
Contributing
- Fork it (https://github.com/your-github-user/kata-mars-rover/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- albertllousas Albert Llousas - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Jun 16, 2019
- Crystal
0.25.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/allousas/kata-mars-rover
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 17, 2026
- Synced
- Aug 17, 2026
- Versions
- 1