Tuesday, September 14, 2010

HW 3: Zuckerville

For your second homework you will implement the text-only farming game Zuckerville: a game for suckers digital farmers! Each player in this game has a plot of land that where he can plant some seeds. After 10 time steps these seeds will have grown into pretty flowers, at which point the player can plant more seeds, if he can afford them.

farmville

Below is a sample interaction of the player with the game.

Welcome to Zuckerville, where the only way to win is not to play!
We gave you $5 zuckerdollars to get you started! Now go plant!

[0 $5] Command: plant
[1 $5] Command: buy 5
You bought 5 seeds.
[2 $0] Command: plant
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
[3 $0] Command: plant
Sorry, there are already seeds planted there. You must wait till after harvest.
[4 $0] Command: fertilize
Sorry, it costs $4 to buy fertilizer.
[5 $0] Command: wait
What did you say?
[6 $0] Command: kdkdk
What did you say?
[7 $0] Command: gossip
What did you say?
[8 $0] Command: chat
What did you say?
[9 $0] Command: help
What did you say?
[10 $0] Command: oh
What did you say?
[11 $0] Command: I
What did you say?
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
[12 $0] Command: plant
[13 $0] Command: buy 10
Sorry, you don't have enough zuckerdollars.
[14 $0] Command: deposit $10
You now have $10
[15 $10] Command: buy 10
You bought 10 seeds.
[16 $0] Command: plant
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
Planted a seed.
[17 $0] Command: fertilize
Sorry, it costs $4 to buy fertilizer.
[18 $0] Command: deposit $4
You now have $4
[19 $4] Command: fertilize
You fertilized your plot!
[20 $0] Command: wait
What did you say?
[21 $0] Command: w
What did you say?
[22 $0] Command: a
What did you say?
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
You harvested a beautiful flower.
[23 $0] Command: quit
Goodbye!

As you can see, the game always gives the user a prompt (like [23 $0] Command:) where the first number (23) is the time and the second ($0) is the money (zuckerdollars) the user has in the game. The user has a few commands he can use:

  1. plant: the user plants all the seeds he has in his plot, but only if the plot is empty. If he has no seeds then nothing happens. If planting succeeds then the plot is now full; no more plantings are allowed until after the plants are harvested.
  2. fertilize: Normally seeds turn into flowers after 10 time steps but if they are fertilized then they grow twice as fast. Fertilizing costs $4.
  3. deposit $x, where x is the number of dollars the sucker player wants to paypal over to us. This code increases the player's zuckerdollars by x.
  4. buy x: the user buys x seeds, each seed costs 1 zuckerdollar. Make sure he has enough money to pay!
  5. quit: the game ends and the program exits.

The user sees a message for every seed he plants and every flower he harvests, as shown in the interaction above.

This program is due Tuesday, 21 September @9am in our dropbox.

No comments: