Difference between revisions of "Lemonade Stand"
(Upload of my implementation) |
|||
Line 25: | Line 25: | ||
==Code so far== | ==Code so far== | ||
− | < | + | <pre> |
+ | #!/usr/env python | ||
+ | |||
+ | def take_input(text, default = 0): | ||
+ | try: | ||
+ | in_text = input(text+" ["+`default`+"]: ") | ||
+ | except: | ||
+ | return default | ||
+ | return in_text | ||
+ | |||
+ | # default values | ||
+ | cup_price = .25 | ||
+ | lemon_price = 1.00 | ||
+ | sugar_price = .05 | ||
+ | |||
+ | product_price = 1.50 | ||
+ | |||
+ | #starting resources | ||
+ | bank = 100 | ||
+ | |||
+ | stored_cups = 0 | ||
+ | stored_lemons = 0 | ||
+ | stored_sugar = 0 | ||
+ | |||
+ | # take in input | ||
+ | num_days = take_input("How many days", 30) | ||
+ | |||
+ | for day in range(1, num_days + 1): | ||
+ | |||
+ | print "Day number "+`day` | ||
+ | |||
+ | print "You have "+`stored_cups`+" cups, "+`stored_lemons`+" lemons, and "+`stored_sugar`+" sugar left." | ||
+ | |||
+ | print "Cup price: $"+`cup_price` | ||
+ | print "Lemon price: $"+`lemon_price` | ||
+ | print "Sugar price: $"+`sugar_price` | ||
+ | |||
+ | expenses = 0 | ||
+ | |||
+ | in_num = take_input("How many cups") | ||
+ | expenses += in_num * cup_price | ||
+ | stored_cups += in_num | ||
+ | |||
+ | in_num = take_input("How many lemons") | ||
+ | expenses += in_num * lemon_price | ||
+ | stored_lemons += in_num | ||
+ | |||
+ | in_num = take_input("How much sugar") | ||
+ | expenses += in_num * sugar_price | ||
+ | stored_sugar += in_num | ||
+ | |||
+ | today = min(stored_cups, stored_lemons, stored_sugar) | ||
+ | |||
+ | # Option 1: make maximum available | ||
+ | #stored_cups -= today | ||
+ | #stored_lemons -= today | ||
+ | #stored_sugar -= today | ||
+ | #print `today`+" cups made for $"+`expenses` | ||
+ | |||
+ | #default value | ||
+ | requested_sales = 5 | ||
+ | sales = min(today, requested_sales) | ||
+ | |||
+ | # Option 2: make as many as requested | ||
+ | stored_cups -= sales | ||
+ | stored_lemons -= sales | ||
+ | stored_sugar -= sales | ||
+ | print `sales`+" cups made for $"+`expenses` | ||
+ | |||
+ | profit = sales * product_price | ||
+ | print `sales`+" cups were sold today for $"+`profit` | ||
+ | print "You made $"+`(profit - expenses)`+" today." | ||
+ | bank += profit - expenses | ||
+ | print "Current funds: $"+`bank` | ||
+ | print "Done!" | ||
+ | </pre> | ||
+ | |||
+ | Alternate Implementation: | ||
+ | <pre> | ||
def supplyReduce(): | def supplyReduce(): | ||
global cups, lemons, ice | global cups, lemons, ice | ||
Line 86: | Line 164: | ||
supplyReduce() | supplyReduce() | ||
today += 1 | today += 1 | ||
− | + | </pre> | |
− | </ |
Revision as of 11:02, 20 April 2009
Group Members
Idea
This is your basic "Lemonade Stand" style game, where the player manages a lemonade stand (or similar such store) and tries to make as much money as possible.
Goals
We're looking to create a workable prototype with the ability to buy materials and sell a product.
Potential Problems
Localization is likely to be a big problem in this game. Not simply translating the words, but also translating the idea, ie. finding out what kind of shop would be reasonable to open in a country, what it might stock, etc.
Wishlist Ideas
Weather patterns impacting sales
Making change (introduction to currency/fractions/small decimals)
Advanced mode: changing the recipie for your "lemonade"
Bargaining/haggling
Random events that may influence supplies and/or cost and/or customers
Potential use of network, competitive or cooperative modes
Code so far
#!/usr/env python def take_input(text, default = 0): try: in_text = input(text+" ["+`default`+"]: ") except: return default return in_text # default values cup_price = .25 lemon_price = 1.00 sugar_price = .05 product_price = 1.50 #starting resources bank = 100 stored_cups = 0 stored_lemons = 0 stored_sugar = 0 # take in input num_days = take_input("How many days", 30) for day in range(1, num_days + 1): print "Day number "+`day` print "You have "+`stored_cups`+" cups, "+`stored_lemons`+" lemons, and "+`stored_sugar`+" sugar left." print "Cup price: $"+`cup_price` print "Lemon price: $"+`lemon_price` print "Sugar price: $"+`sugar_price` expenses = 0 in_num = take_input("How many cups") expenses += in_num * cup_price stored_cups += in_num in_num = take_input("How many lemons") expenses += in_num * lemon_price stored_lemons += in_num in_num = take_input("How much sugar") expenses += in_num * sugar_price stored_sugar += in_num today = min(stored_cups, stored_lemons, stored_sugar) # Option 1: make maximum available #stored_cups -= today #stored_lemons -= today #stored_sugar -= today #print `today`+" cups made for $"+`expenses` #default value requested_sales = 5 sales = min(today, requested_sales) # Option 2: make as many as requested stored_cups -= sales stored_lemons -= sales stored_sugar -= sales print `sales`+" cups made for $"+`expenses` profit = sales * product_price print `sales`+" cups were sold today for $"+`profit` print "You made $"+`(profit - expenses)`+" today." bank += profit - expenses print "Current funds: $"+`bank` print "Done!"
Alternate Implementation:
def supplyReduce(): global cups, lemons, ice if cups != 0: cups -= 1 if lemons != 0: lemons -= 1 if ice != 0: ice -= 1 print "some of your supplys was stolen by ants!" def makeStuff(): global cups, lemons, ice made = min(cups, lemons, ice ) cups -= made lemons -= made ice -= made print "You made " + str(made) + " cups of lemonade" name = 'lemonade stand' cups = 0 lemons = 0 ice = 0 today = 0 daysToPlay = 0 print "Welcome to " + name daysToPlay = input("How many days would you like to play for: ") while today <= daysToPlay: print " " print "You have" print "cups: " + str(cups) print "lemons: " + str(lemons) print "ice: " + str(ice) print " " try: cupsToAdd = input("How many cups do you want to buy? ") cups += cupsToAdd lemonsToAdd = input("How many lemons do you want to buy? ") lemons += lemonsToAdd iceToAdd = input("How much ice do you want to buy? ") ice += iceToAdd except: print "dont break my program" print " " makeStuff() supplyReduce() today += 1