This is the classic Blocks World, in PHP.
- Implemented in the CLI.
- Block.php contains a data structure class, as this was the most elegant way to capture all and only the requirements for Blocks World. The resulting class in Robot.php has echoes of a linked list (using
class Block), except here we've changedRobot's methods to reflect what theRobotclass does.
- The Script Runs on Text Files. Out of the box, I've included an input.txt file with some sample input:
- Download the project
- Go to the project's root directory
- Run the following:
php bot input.txt
- Including Your Own Input File.
- Create a text file with the following possible keywords:
# Comments can be placed on any line 15 blocks print move x onto y print move x over y print pile x onto y print pile x over y- Concretely:
25 blocks print move 8 onto 4 print pile 6 onto 3 # ...
- Concretely:
- Place the file in the project's root directory.
- Run it from the project's root directory:
php bot [your txt file] - If you prefer, you can print only the final state of how the blocks end up:
10 blocks move 8 onto 4 pile 6 onto 3 # prints out the final state only: quit
- Create a text file with the following possible keywords:
- Blocks World Uses PHPUnit 11.4. From the project root, type
./tools/phpunit