David Ogilo

menu search

Rock. Paper. Scissors

I recently created a simple program for the game “rock-paper-scissors”, which was for a job application. I decided to publish the code (including PHPUnit tests) on GitHub so if you want to extend or play around with it, please feel free to. The game has two modes – PVC (Player vs. Computer) and CVC (Computer vs. Computer). It can also store the instance and result of your game(s) in case you want to continue on a later date.

The program is very easy to use as shown below:

$ php rps.php --game=pvc rock
 
Game started - to reuse this instance please run game again with --id=q3mftlcemfjt4p79i2iontf4h1
 
The game ended with computer winning, having picked a paper whilst you picked a rock.
 
==== Game Statistics ====
Draws: 0
Wins: 0
Computer wins: 1

You can access more options by using the command php rps.php -h. If you want to run the tests just type the command phpunit in the directory.

Tags: ,

Old school browser detected!

Your browser is out of date, which means you can't use any of the site's required features. You can either upgrade your browser or switch to either Mozilla Firefox or Google Chrome