Home CPSC 220

Chaco Canyon

 

Due: November 9

 

Objective

To practice using classes and objects, and writing simulation programs.
 

Task

For the project, you will write a game program based on ancient Pueblo Culture at what is now Chaco Canyon New Mexico.
 

Introductory Message

Your Chaco Canyon game will begin by presenting the following message to the user:
Congratulations, you are the newest leader of ancient Chaco Canyon, elected for
a ten-year term of office. Your duties are to dispense food, direct farming,
and buy and sell land as needed to support your people. Watch out for rat
infestations and the drought! Maize is the general currency, measured in
bushels. The following will help you in your decisions:

 - Each person needs at least 20 bushels of maize per year to survive.
 - Each person can farm at most 10 acres of land.
 - It takes 2 bushels of maize to farm an acre of land.
 - The market price for land fluctuates yearly.

Rule wisely and you will be showered with appreciation at the end of your term.
Rule poorly and you will be kicked out of office!

 

Initial Values

Values When you implement your ChacoCanyonSimulation class, you will require instance variables to capture the state of Chaco Canyon. The following provides the initial values for your instance variables.


 

Simulating a Year

As the leader of Chaco Canyon you have to make decisions for each year, which are the following.

You should think of your simulation as a big loop. On each iteration of your loop, you will ask the user the above questions, which provide the input parameters for a method described in the next section. The following shows the initial state message followed by three questions. The printout will occur each year, with the state information changing based on the leaders decisions.

O great Chaco Leader, I beg to report to you, In the year 1000, 0 people
starved to death, 0 people left our nation, 0 people entered our nation.  The
population is now 100.  The nation now owns 1000 acres.  We harvested 3000
bushels at 3 bushels per acre.  Rats destroyed 0 bushels, leaving 3000 bushels
in storage.  Land is currently worth 20 bushels per acre.

How many acres do you wish to buy? 10
How many acres to you wish to sell? 0
How many bushels of maize do you wish to feed your people? 2000
How many acres do you wish to plant with seed? 400

A player who is buying land is not allowed to sell land during the same year. Make sure you do a sanity check of all player input. For example, you cannot plant 1000 acres when you only have 204 bushels of maize.

At the end (either after 10 years or failure), print out a final summary, and tell the player how good a job he/she did. The details are up to you, but the usual evaluation is based on how many people starved, and how many acres per person you end up with.


 

Simulation Attributes

When you simulate a year in Chaco Canyon, your simulation algorithm with use as input the current state defined by your instance variables and the four input parameters collected from the user:

Current State: year, population, acres of land, value of land, maize in storage.

Input Parameters: acres to buy, acres to sell, maize to feed, acres to plant.

The computational attributes of your simulation algorithm are defined by the following.

  1. Drought - Affects your population. Each year there is a 15% chance of a horrible drought. When this happens your population is affected as 30% of the people die and 20% leave.
  2. Starvation - Uses your current population and input parameter maize to feed. If you do not provide enough maize for the people to eat, some will starve. Each person needs 20 bushels of maize to survive. If you feed them more than this, they are happy. For example, if you have a population of 100 and you feed them 1900 bushels of maize, five people will starve that year.
  3. If more than 45% of the people die or leave (either via this Starvation of via Drought) you will be immediately thrown out of office. For the initial values provided above, this means if your population dips below 55, you will be thrown out of office. In that case print some harsh message and exit the program.

  4. Immigrants - Affects your population. A thriving Chaco Canyon attracts immigrants. How many people came to the city? Nobody will come to the city in the year where some people starve as defined by the Starvation attribute. If everyone is well fed, compute how many people come to the city as:

    $(\frac{20 \times acres + grain}{100 \times population} + 1) \times P$

    Where $P$ is a random floating point number between 0 and 1. This can be produced by the "nextDouble" function of the Random class. However, only a whole number person can come to the city (you cannot have 2.5 people arriving into the city).

  5. Harvest - Affects your maize in storage. How good is the harvest? Choose a random number between 1 and 8, inclusive. Each acre that was planted with seed will yield this many bushels of maize. (Example: if you planted 50 acres, and your number is 3, you harvest 150 bushels of maize).
  6. Rat Infestation - Affects your maize in storage. There is a 50% chance that you will have a rat infestation. When this happens, rats will eat somewhere between $\frac{1}{25}$ and $\frac{4}{10}$ of your grain.
  7. Land Valuation - Affects value of land for next year. The price of land is random, and ranges from 17 to 26 bushels per acre. The player will need this information in order to buy or sell land.

All computations should use doubles for intermediate values, but ultimately produce integers.


 

Sample Run

Congratulations, you are the newest leader of ancient Chaco Canyon, elected for
a ten year term of office. Your duties are to dispense food, direct farming,
and buy and sell land as needed to support your people. Watch out for rat
infestations and the drought! Maize is the general currency, measured in
bushels. The following will help you in your decisions:

  * Each person needs at least 20 bushels of maize per year to survive.
  * Each person can farm at most 10 acres of land.
  * It takes 2 bushels of maize to farm an acre of land.
  * The market price for land fluctuates yearly.  Rule wisely and you will be
    showered with appreciation at the end of your term. Rule poorly and you will be
    kicked out of office!

O great Chaco Leader, I beg to report to you, In the year 1000, 0 people
starved to death, 0 people left our nation, 0 people entered our nation.  The
population is now 100.  The nation now owns 1000 acres.  We harvested 3000
bushels at 3 bushels per acre.  Rats destroyed 0 bushels, leaving 3000 bushels
in storage.  Land is currently worth 20 bushels per acre.

How many acres do you wish to buy? 10
How many bushels of maize do you wish to feed your people? 2000
How many acres do you wish to plant with seed? 400

O great Chaco Leader, I beg to report to you, In the year 1001, 0 people
starved to death, 0 people left our nation, 5 people entered our nation.  The
population is now 105.  The nation now owns 1010 acres.  We harvested 1600
bushels at 4 bushels per acre.  Rats destroyed 100 bushels, leaving 1500
bushels in storage.  Land is currently worth 21 bushels per acre.

How many acres do you wish to buy? 0
How many bushels of maize do you wish to feed your people? 1200
How many acres do you wish to plant with seed? 1000
O honorable leader, Think again, You only have 300 bushels of maize. Now then,
How many acres do you wish to plan with seed? 150

O great Chaco Leader, I beg to report to you, In the year 1002, 40 people
starved to death, 0 people left our nation, 0 people entered our nation.  The
population is now 60.  The nation now owns 1010 acres.  We harvested 750
bushels at 150 bushels per acre.  Rats destroyed 0 bushels, leaving 750 bushels
in storage.  Land is currently worth 20 bushels per acre.
...

 

Implementation Details


 

General Requirements


 

Submitting

To submit your program, email the code to ifinlay@umw.edu.

Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.