from random import randint from math import floor eventList = {1954:["Robert Patterson requests to form the Citizen's Council.", "Brown v. Board encourages schools to be integrated", "The KKK requests holding a rally"], 1955:["Reverend George Lee is murdered. No allegations are made.", "White schools request a slowed reaction to Brown v. Board II", "Jury acquits Roy Bryant and J. W. Milam in Emmett Till murder"], 1956:["The Southern Manifesto is written to defy integration", "You are asked to sign the Sovereignty Bill into law", "The NAACP requests that you give a speech about integration"], 1957:["Segregation films are requested to be implemented into schools", "You are asked to endorse the Voting Rights Act of 1957 by a member of congress", "NAACP refuses to turn over their memebership lists"], 1958:["Clennon Washington King, Jr. attempts to enroll at Ole Miss", "The film 'The Horse Soldiers' is to be made at Jefferson College", "Decreased property taxes are proposed"], 1959:["The opportunity arises to renovate the Old Capitol", "Gilbert Mason petitions to integrate the Biloxi Municipal School District", "A white mob abducts Mack Charles Parker from jail and kills him. No one accused."], 1960:["Gilbert Mason requests to lead a demonstration to integrate public beaches.", "Bob Moses comes to visit Amzie Moore. He requests a meeting with you.", "You are asked to endorse Senator Harry Byrd for President of the U.S."], 1961:["Police arrest the Tougaloo Nine.", "Freedom Riders move through the State challenging bus segregation.", "SNCC requests a voter registration drive in Pike County."], 1962:["Jackson Nonviolent Movement organizes bus boycott in Jackson", "The Federal Court forces Ole Miss to accept James Meredith", "Leflore County officials cut off food distribution to rural areas"], 1963:["600 Blacks congregate in Jackson and request steps towards integration.", "Sit-ins occurr at Woolworth's.", "Byron de la Beckwith arrested for murder of Medgar Evers"], 1964:["Consituents urge you to maintain poll taxes for state elections", "The KKK kills Henry Dee and Charles Moore with no pressed charges.", "The Mississippi Freedom Democratic Party challenges \nthe all white State Convention"], 1965:["District Judge Harold Cox of Jackson dismisses Chaney, Goodman, Schwerner case.", "Schools in Greenville integrated without court order", "The SCLC registers black voters of the southern counties"], 1966:["You are asked to pass the National Historic Preservation Act", "The KKK firebomb Vernon Dahmer's house and store", "MLK, Stokeley Carmichael, and Floyd McKissick request \ncompleting the March against Fear"], 1967:["You are asked to endorse Robert Clark for the House of Representatives", "Riots break out in major cities. You are requested to take action.", "Several schools request to be desegregated"], 1968:["You are asked to lead the Poor People's Campaign March", "You are asked to endorse the Housing and Urban Development Act", "The FBI requests information you have on the KKK bombing plots"], 1969:["You are asked to sign a bill requiring desegregation of schools", "You are asked to endorse Charles Evers for Mayor of Fayette", "The NAACP requests the integration of the Highland Park Pool"]} pointList = {1954:[-1.5,1,1.5,-2,-2,.25],1955:[-.25,2.5,-.5,1,-.25,.5],1956:[-1,1.5,-1.5,2,.25,-.75], 1957:[-1,.75,.5,-.75,.25,0],1958:[1.5,-2,0,.15,.15,.5],1959:[0,.25,1.5,-1.25,-.15,0], 1960:[.5,-1,.15,0,-.15,.5],1961:[-.75,.15,1,-1.25,1.5,-1],1962:[1,-.75,1,-1.5,-.5,-.15], 1963:[.25,-.5,1.25,-1.75,1,0],1964:[-2,1.5,-.5,.15,2,-1.5],1965:[-.5,.15,2,-.5,1,-.25], 1966:[0,.15,-.25,.05,.15,-.1],1967:[2,-1.5,.25,.15,.75,-.1],1968:[.1,.25,.1,.15,.25,0], 1969:[1.5,-1,1.25,-.5,.5,-.5]} class Player: def __init__(self, name, civilScore, electionScore): self.name = name self.civilScore = civilScore self.electionScore = electionScore def electionCheck(self): odds = randint(0, 7) if self.electionScore >= 10: self.electionScore = 10 if self.electionScore > 7: if odds > 0 or self.electionScore == 10: return True else: return False elif self.electionScore >= odds and self.electionScore > 2: return True else: return False def approvalRating(self): percentage = floor(self.electionScore * 10) if percentage > 100: percentage = 100 print("\nPolls indicate you have an approval rating of %s percent." % (percentage)) if percentage <= 60: input("Perhaps you should consider realigning your ideals to your constituents") else: input("Perhaps you could use this approval buffer to advance Civil Rights") x = Player("",0,5) def event(year, iterable, player): events = eventList[year] event = events[iterable] reactions = pointList[year] print("\n" + event) action = input("Do you allow this? (Y/N) ").upper() if action == "Y": print("Action permitted") player.civilScore += reactions[iterable*2] player.electionScore += reactions[(iterable*2)+1] else: print("Action not allowed") player.civilScore -= reactions[iterable*2] player.electionScore -= reactions[(iterable*2)+1] def startUp(player): newName = input("What is your name? ") player.name = newName year = int(input("Which election year, 1954-1960, would you like to start in? ")) if year % 2 != 0: year += 1 if year < 1954: year = 1954 elif year > 1960: year = 1960 start = year print("\nWelcome Governor %s! You have just been elected\n" "to this position by popular vote in the %s Mississippi\n" "gubernatorial election! Hopefully you will use this new\n" "position to better this great State. \n\n" "Over the course of your term, several events will take\n" "place each year. Your goal is to balance the progression\n" "of the Civil Rights movement with the ideals of your general\n" "population. Your decisions regarding these events will shape\n" "not only your own future, but that of Mississippi.\n\n" "So choose wisely\n" % (player.name, year)) while year < 1970: terms = int((year - start)/2) print("\n" + str(year)) if year % 2 == 0 and year != start: if player.electionCheck(): print("\nCongratulations, you have been elected for\n" "for another term!") else: print("\nDue to low standings in the poll, you\n" "were not re-elected to office.\n") print("You were able to maintain office for %s terms." % (terms)) break for i in range(3): event(year, i, player) player.approvalRating() year += 1 if year == 1970: print("Congratulations Governor %s! You have survived %s terms and\n" "have had a major impact on the State of Mississippi.\n" % (player.name, terms)) score = floor(player.civilScore * 3) if score < 0: print("It seems your years in office have not been kind to\n" "the Civil Rights movement, Governor %s. You have set\n" "back the movement in Mississippi by %s years." % (player.name, -score)) else: print("It seems history will remember you as a progressive\n" "Civil Rights leader, Governor %s! You have pushed\n" "the movement forward in Mississippi by %s years." % (player.name, score)) else: score = floor(player.civilScore / 2) if score > 0: print("Even though your time in office may have been cut\n" "short Governor %s, you still managed to advance the\n" "Civil Rights Movement in Mississippi by %s years." % (player.name, score)) def play(player): play = True while play: startUp(player) play = input("\nPlay again? (Y/N)").upper() if play == "Y": play = True else: play = False play(x)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question