Solving Mars-rover problem.
A squad of robotic rovers is to be landed by NASA on a plateau on Mars. This plateau, which is curiously rectangular, must be navigated by the rovers so that their on board cameras can get a complete view of the surrounding terrain to send back to Earth. A rover's position is represented by a combination of an x and y co-ordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. An example position might be 0, 0, N, which means the rover is in the bottom left corner and facing North. In order to control a rover, NASA sends a simple string of letters. The possible letters are 'L', 'R' and 'M'. 'L' and 'R' makes the rover spin 90 degrees left or right respectively, without moving from its current spot. 'M' means move forward one grid point, and maintain the same heading. Assume that the square directly North from (x, y) is (x, y+1).
Project is created with:
- php version: 8.0
- Symfony framework
- Docker
- Docker Compose
Before you install project you only need to install Docker | docker-compose
git clone git@github.com:MHNassar/mars-rover.git
cd /mars-rover
docker-compose up --build -d
To check status
docker-compose ps
To install the project
docker exec -it php8_mars_rover composer install
To run the tests
docker exec -it php8_mars_rover php bin/phpunit
To run the Rover Just use this command
docker exec -it php8_mars_rover php bin/console rover:control
- Go to public/input.txt
- Add the rover location and commands
- run the command again
I'm including Symfony and Symfony Components to use the power of dependency injection and console and so on ...
- using Doubly Circular Linked List to manage the direction to get the right and the left direction
- Each Direction has his own Class to apply SRP also make any change in code easy
- Set of functions should control the Rover in the plateau
- The main task of this parser to parse the input and create Input class
- For now Reading input from text file it's Open for add many types of parsers