from random import randrange deaths = [ "The survivers revolt and put a poisinous snake in your \ bed; you die.", "The survivers put poison in your drink; you die.", """You were taking a walk in the night, suddenly hands grab your shoulders... your funerel is very small only your wife is there.""", """You wake up in the middle of the night when you hear your wife scream the assasins are here you knew they would come - there was no food. You see a glint in the air, you try to hide but its to late you and your wife are buried the next morning.""", "The survivors revolt, you are thrown out of a window.", """The survivers revolt, they starve you, whip you till your half dead, then chop your head off.""", """you are riding your horse by a cliff suddenly a stone flys through the air and hits your horse. He rears and you fall into the cliff...""", """ Their is a war because of the lack of food, half the city is on yor side, and the other half is against you, you die fighting.""" ] grain = 2000 people = 500 wisemen = 0 while True: print "There are %d peasants in your city." % people print "You have %d bushels of grain." % grain print "You have %d wisemen." % wisemen promotions = input ("How many peasants do you want to promote to wisemen?") if promotions > people: print "You don't have that many peasants." continue wisemen += promotions people -= promotions print "You now have %d peasants and %d wisemen." % (people, wisemen) plant=input("How much will you plant?") if plant > people: print "With only %d peasants, you can plant at most %d bushels." % ( people,people ) continue food=input("How much food will you give the people?") if food + plant > grain: print "We don't have that much grain." continue yld=randrange(0,11) harvest=yld*plant store=grain-plant-food shrinkage=randrange(10,50)- wisemen/15 if shrinkage < 0: shrinkage = 0 loss=store*shrinkage/100 print "You harvested %d bushels." % harvest print "You stored %d bushels." % store print "the rats ate %d bushels." % loss grain = store - loss + harvest req = people + 2 * wisemen # food required for subsistence if food > req: migration = randrange(0,50) * (food - people) / 100 print "%d peasants came to the city." % migration people = people + migration elif food < req: starved = max(req - food,people) print "%d peasants starved." % starved people = people - starved if starved > people /2: print deaths[randrange(0,len(deaths))] break