Oz N Tiram a5aebb35bc Update the README | 4 년 전 | |
---|---|---|
src | 4 년 전 | |
tests | 4 년 전 | |
.gitignore | 4 년 전 | |
Makefile | 4 년 전 | |
Pipfile | 4 년 전 | |
README.md | 4 년 전 | |
requirements-test.txt | 4 년 전 | |
requirements.txt | 4 년 전 | |
setup.cfg | 4 년 전 | |
setup.py | 4 년 전 |
This is a solution to the Kata in Python3.
The requirements to run this code are:
To run the code create a virtual environment and install the dependencies and then the code itself. If you are familiar with Python you can also use pipenv and skip the following instructions:
# These istructions assume you use a shell on a UNIX like system (Mac or Linux)
$ python3 -m venv rover-env
$ source rover-env/bin/activate
$ pip install -r requirements.txt
If you have GNU Make installed on your system you can simply use:
$ make setup/dev
$ source rover/env/activate
Here is a short example how one can use the Rover class:
Land at user specified location
>>> r = Rover(x=2, y=2, heading='N')
>>> r.move("FFF")
Location (2, 5) Heading N
Land at random location:
>>> from rover import Rover
>>> r = Rover()
/home/oznt/Software/mars-rover/src/rover/rover.py:20: UserWarning: Landing at a random place
warnings.warn("Landing at a random place")
>>> r.location
<rover.rover.Location object at 0x7f3dae21e160>
>>> r.location.x
9
>>> r.location.y
-8
>>> r.location.heading
'S'
>>> r.location.heading = 'N'
>>> r.move('FFF')
Location (9, -5) Heading N
The interface is very minimal and on can only land and move the rover towards the north and the east.