Write a shell script named stick which plays a matchstick

Assignment Help Computer Engineering
Reference no: EM132383504

Programming Assignment

For assignment , 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.

Usage

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

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:

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).

Algorithm

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

Reference no: EM132383504

Questions Cloud

Compile a database of jobs and skills : Type into the search criteria a career you are interested in ie "biomedical engineering", "software developer", "network engineer".
What methods can be used for sentiment analysis : Compare and contrast Hadoop, Pig, Hive, and HBase. List strengths and weaknesses of each tool set. What methods can be used for sentiment analysis?
How to use it security policy framework to help : Create a presentation that can be used to instruct individuals and groups on how to use IT Security Policy Framework to help with the alignment.
Find a nearly continuous flow of substances back : If we inspect most cell membranes in a living human body, we would find a nearly continuous flow of substances back and forth across the plasma membrane.
Write a shell script named stick which plays a matchstick : Write a shell script named stick which plays a matchstick-picking game. Given an initial number of sticks, players take turns picking.
What is the best way to measure bone density : a. Explain how aging and the lack of estrogen contribute to the development of osteoporosis.
Why is it important for organisms to maintain a ph : Why is it important for organisms to maintain a pH within a very narrow range and what type of a compound (molecule) is used to help maintain that narrow range?
Create a count-controlled while loop to generate : Create a count-controlled while loop to generate and append 1,000 random integers to the list. Each integer should be between 1 and 100, including 1 and 100.
How your current practice may change in the future : Discuss how your current practice may change in the future as a result of your understanding of one particular Essential of Master's Education in Nursing.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd