Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!


Bash Script “Stick Game”

Bash Script “Stick Game”

Bash Script “Stick Game”

For assignment 1, you need to write a shell script named �stick� which plays a matchstick-picking game. Given an initial number of sticks, players take turns picking either 1, 2 or 3 sticks from a pile. Whoever picks the last stick wins.


You run stick without any command line arguments, i.e.


The game should greet the user, and then ask how many sticks to play with (must be an integer ≥ 10), and who should go �rst (c for computer, u for user). An invalid answer should cause the program to re-ask the question (as many times as necessary).

On the user’s turn, ask the user how many sticks to remove, and remove those from the pile. On the computer’s turn, calculate the correct number of sticks to remove in order to ensure you will (hopefully) win the game.

Play continues until there are no sticks left, at which point your program announces who won. You must show the set of sticks after each player’s move. Show this as a set of pipes (�|�) side by side, followed by the number of sticks in (parenthesis), for example:

||||||| (7)

Illegal Moves

When the user is asked how many sticks to take, they must enter 1, 2 or 3. If their entry is illegal (anything other than 1 2 or 3), remind them of their options, and ask once more. If they enter another illegal number, announce that they have forfeited the game, and terminate the program. If the user entered a valid number the second try, gameplay continues (in this case, if later the user again enters an illegal number, you should again given them a second chance).



Your algorithm for picking sticks is simple: given n remaining sticks, pick (n mod 4) sticks, unless (n mod 4)=0; in that case, pick 1 stick.

Other Requirements

• your program must be written as a bash script

• make frequent backups! It’s easy to lose your work; it’s your responsibility to make sure you can recover from this.

• you must comment your script thoroughly, including a block of comments in the beginning describing:

� your name, the course, the date, and the assignment number

� a synopsis in your own words of what the script does

If you don’t include this block of comments, your program will receive a grade of 0.


You must submit this assignment via GIT. Using the same username you sup- plied in HW 1, create a new repository named PA1 (it must be named PA1 (uppercase P and A, no spaces, etc.)). The download is automated, and it will only look for a repo with the name PA1. Make sure your repo is available by the due date/time.

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Writers Hero only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Writers Hero are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Writers Hero is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Writers Hero, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.