diff --git a/Class_Country.py b/Class_Country.py new file mode 100644 index 0000000..0901eb9 --- /dev/null +++ b/Class_Country.py @@ -0,0 +1,26 @@ +""" +defining class country +Subeen Kim +""" + +class country: + + def __init__(self, max_pop, infected_pop=0, infection_rate=1.1, center_x=100, center_y=200, radius=30): + self.max_pop = max_pop + self.infected_pop = infected_pop + self.infection_rate = infection_rate + self.center_x = center_x + self.center_y = center_y + self.radius = radius + + def number_infection(self, click): + """ click gets True of False from the mouse click """ + while click: + self.infected_pop = self.infected_pop*self.infection_rate + if self.infected_pop >= self.max_pop: + break + return int(self.infected_pop) + +Egypt = country(1) +Egypt.max_pop = 100 +number_infection(Egypt, True) diff --git a/Country.py b/Country.py new file mode 100644 index 0000000..91b14d1 --- /dev/null +++ b/Country.py @@ -0,0 +1,323 @@ +import os +import pygame +import random + +BLACK = (0, 0, 0) +RED = (255, 0, 0) +GREEN = (0, 255, 0) +BLUE = (0, 0, 255) + + +pygame.init() +font = pygame.font.SysFont('Consolas', 20) + +class Doctor: + """ + Doctor begins to work on a cure after a certain amount of upgrades + or after time has elapsed for a certain time + """ + def __init__(self, timer=120, rate=1, percent=0): + """ Timer is set for when the cure will be started + Rate is at what rate the cure is being develop + If cure.percent is 100 percent the game is over + """ + self.timer = timer + self.rate = rate + self.percent = percent + +class Country: + """ + Each country has its maximum population without any infected people, + before we click the country in the beginning of the game. + """ + def __init__(self, x, y, max_pop, radius=50, color=RED, infected_pop=0, infected_rate=1.1, dead_pop=0, death_rate=1, airborne_rate=0): + """ + Position and color of each country are defined. + Population(Infected, death, toal), and Rate(Infection, death, airborne) are defined. + """ + self.initial_pos = (x, y) + self.x = x + self.y = y + self.color = color + self.radius = radius + self.infected_pop = infected_pop + self.infected_rate = infected_rate + self.max_pop = max_pop + self.dead_pop = dead_pop + self.death_rate = death_rate + self.airborne_rate = airborne_rate + + def infected_ratio(self): + """ + The ratio of infection (population of infected people / toal population of a country) + """ + if self.max_pop != 0: + return int(self.infected_pop) / self.max_pop + else: + return 1 + + def death(self): + """ + A part of the infected population would be killed. + Then the infected population and maximum population will be reduced as many as the number of people death. + """ + death_pop = 0 + alive_pop = self.max_pop + if self.infected_ratio() > 0.10: #ratios are arbitrarily selected + if self.infected_pop > 15: + death_pop = int(self.death_rate*self.infected_pop*(random.random()/15)) + else: #once population hits below 15, we no longer use a ratio + if self.max_pop >= 1: + death_pop = 1 + else: + death_pop = 0 + + self.infected_pop = self.infected_pop - death_pop + self.max_pop -= death_pop + self.dead_pop += death_pop + + def step(self): + """ + If infection starts (infect_pop changed into unity), + then the infection starts with the certain rate + + When infected population is at max pop, the infection rate stops. + """ + if self.infected_pop < self.max_pop: + self.infected_pop = self.infected_pop * self.infected_rate + if self.infected_pop >= self.max_pop: + self.infected_pop = self.max_pop + + """return integer part of infected population""" + # return int(self.infected_pop) + + """return probability""" + return self.infected_ratio() + + + def draw(self): + """ draws the location of the country as a circle """ + pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), + self.radius) + + def contains_pt(self, pt): + """ countains points function to see if mouseclicks are + within the circles of the country """ + x, y = pt + if not self.x - self.radius < x < self.x + self.radius: + return False + if not self.y - self.radius < y < self.y + self.radius: + return False + return True + + def propagation(self, other): + """ + The pathogen can propagate to other countries with certain probability. + """ + if self.infected_pop >= 1 and other.infected_pop == 0: + if random.random() <= self.infected_ratio()/10: + other.infected_pop = 1 + +"""Varibles for pygame display""" +background_color = (255,255,255) +width, height = 640, 480 + +screen = pygame.display.set_mode((width, height)) +pygame.display.set_caption('Plague Simulation') +screen.fill(background_color) + +intro = True + +while intro: + """ Intro of the game gives the intro screen with + upgrade instructions as well as how to start the game """ + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + quit() + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_c: + intro = False + running = True + if event.key == pygame.K_q: + pygame.quit() + quit() + """ Renders the text where it tells the user to + press c to start the game, and gives instructions on how to upgrade the game""" + + basicfont = pygame.font.SysFont(None, 20) + text = basicfont.render('Welcome To A Plague Simulation! Press C to Start, Click on a country to start your infection', True, (0, 0, 0), (255, 255, 255)) + textrect = text.get_rect() + textrect.centerx = screen.get_rect().centerx + textrect.centery = screen.get_rect().centery + screen.blit(text, textrect) + screen.blit(basicfont.render('For Upgrades, Press I to increase infection rate, K to increase kill rate, and A to increase airborne rate' , True, (0, 0, 0), (255, 255, 255)), (0, 300 )) + + pygame.display.update() + +screen = pygame.display.set_mode((640, 480)) + +""" Herein, three countries are defined as well as the doctor """ +country1 = Country(200, 120, 200, radius=60) +country2 = Country(500, 180, 200, radius=40, color=BLUE) +country3 = Country(320, 360, 200, radius=50, color=GREEN) +countries = [country1, country2, country3] +country_pop_index = country1 +total_pop = 0 + +doctor1 = Doctor() + +Time = 0 +time = 0 +upgrades = 0 +Upgrade_Point = 0 +infectionindex = 1 +""" This is the counter to allow you to +click on a country and place a pathogen""" +clock = pygame.time.Clock() + + +""" Pressing C will officially start the game running our +game function with time""" + +running = True +while running: # forever -- until user clicks in close box + for event in pygame.event.get(): + if event.type == pygame.MOUSEBUTTONDOWN: + for country in countries: + """ start of the game, clicking the first country + will place the first pathogen in the country """ + if country.contains_pt(pygame.mouse.get_pos()): + if infectionindex == 1: + country.infected_pop = country.infected_pop + 1 + infectionindex = infectionindex - 1 + country_pop_index = country + """now our pathogen embarks on infection!""" + + """Upgrade functions that cost more and more as upgrades increase""" + if event.type == pygame.KEYDOWN: + #Upgrade infection rate + if event.key == pygame.K_i: + if Upgrade_Point > upgrades**2: + for country in countries: + country.infected_rate = country.infected_rate * 1.15 + Upgrade_Point = Upgrade_Point - upgrades**2 + upgrades = upgrades + 1 + print (country.infected_rate) + + #increase kill rate + if event.key == pygame.K_k: + if Upgrade_Point > upgrades**2: + for country in countries: + country.death_rate = country.death_rate * 1.15 + Upgrade_Point = Upgrade_Point - upgrades**2 + upgrades = upgrades + 1 + print (country.death_rate) + #increase airborne capacity + if event.key == pygame.K_a: + if Upgrade_Point > upgrades**2: + for country in countries: + country.airborne_rate = country.airborne_rate + 0.15 + Upgrade_Point = Upgrade_Point - upgrades**2 + upgrades = upgrades + 1 + print (country.airborne_rate) + + """Modify Time + XXXX to modify the speed of the game.""" + if pygame.time.get_ticks() > (Time + 1000): + Time = pygame.time.get_ticks() + """ If population == 0 then game is over""" + if all(country.max_pop == 0 for country in countries) == True: + running = False + endscreen = True + #print ('For each country: (infected ratio, total population)', (country1.infected_ratio(),country1.max_pop), (country2.infected_ratio(),country2.max_pop), (country3.infected_ratio(),country3.max_pop)) + Total_infected = 0 + """ + Doctor starts working if time is above a certain time or if upgrade counts + are more than 3 + + Once cure is started, the percent increments by the cure rate + """ + if (upgrades > 3) or (pygame.time.get_ticks() > (doctor1.timer * 1000)): + doctor1.percent = doctor1.percent + (doctor1.rate) + if doctor1.percent == 100: + running = False + lose = True #if doctor cure hits 100% lost screen is played + """ + Infection types: step, death, propagation + Upgrade Point is given at every step. + """ + for country in countries: + country.step() + country.death() + Total_infected += (country.infected_pop + country.dead_pop) + if infectionindex == 0: + if country.max_pop !=0: + if pygame.time.get_ticks() > (time + 4000): + time = pygame.time.get_ticks() + Upgrade_Point += random.randint(1,3) + for other in countries: + if country != other: + country.propagation(other) + + if event.type == pygame.QUIT: + running = False + + screen.fill(BLACK) # erases screen + for country in countries: + country.draw() + + """ + the number of infected, dead, and total population is displayed whenever we click certain country + """ + screen.blit(font.render('Infected:%.2d'%(country_pop_index.infected_pop) + ' ' +'Dead:%.2d'%(country_pop_index.dead_pop) + ' '+ 'Alive:%.2d'%(country_pop_index.max_pop) +' '+'Upgrade Point:%.2d'%(Upgrade_Point) , True, (0, 255, 255)), (0, 440)) + screen.blit(font.render('Current Upgrades:%.2d'%(upgrades), True, (0, 255, 255)), (400, 400)) + screen.blit(font.render('Current Cure Percentage:%.2d'%(doctor1.percent), True, (0, 255, 255)), (0, 400)) + pygame.display.update() # updates real screen from staged screen + +endscreen = False +"""End screen when everyone is dead """ +while endscreen: + screen.fill(background_color) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + quit() + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_q: + pygame.quit() + quit() + + + text = basicfont.render('Congradulations you have killed everyone! Press Q to end the game.', True, (0, 0, 0), (255, 255, 255)) + textrect = text.get_rect() + textrect.centerx = screen.get_rect().centerx + textrect.centery = screen.get_rect().centery + screen.blit(text, textrect) + + pygame.display.update() + +"""Endscreen when the disease is cured""" +while lose: + screen.fill(background_color) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + quit() + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_q: + pygame.quit() + quit() + + + text = basicfont.render('The Doctor Has Cured Your Disease! Press Q to end the game.', True, (0, 0, 0), (255, 255, 255)) + textrect = text.get_rect() + textrect.centerx = screen.get_rect().centerx + textrect.centery = screen.get_rect().centery + screen.blit(text, textrect) + + pygame.display.update() + +pygame.quit() diff --git a/Population_Ranking.csv b/Population_Ranking.csv new file mode 100644 index 0000000..90e7316 --- /dev/null +++ b/Population_Ranking.csv @@ -0,0 +1,327 @@ +,Population 2016,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,Ranking,,Economy,(thousands),,,,,,, +,,,,,,,,,,, +CHN,1,,China,"1,378,665",,,,,,, +IND,2,,India,"1,324,171",,,,,,, +USA,3,,United States,"323,128",,,,,,, +IDN,4,,Indonesia,"261,115",,,,,,, +BRA,5,,Brazil,"207,653",,,,,,, +PAK,6,,Pakistan,"193,203",,,,,,, +NGA,7,,Nigeria,"185,990",,,,,,, +BGD,8,,Bangladesh,"162,952",,,,,,, +RUS,9,,Russian Federation,"144,342",,,,,,, +MEX,10,,Mexico,"127,540",,,,,,, +JPN,11,,Japan,"126,995",,,,,,, +PHL,12,,Philippines,"103,320",,,,,,, +ETH,13,,Ethiopia,"102,403",,,,,,, +EGY,14,,"Egypt, Arab Rep.","95,689",,,,,,, +VNM,15,,Vietnam,"92,701",,,,,,, +DEU,16,,Germany,"82,668",,,,,,, +IRN,17,,"Iran, Islamic Rep.","80,277",,,,,,, +TUR,18,,Turkey,"79,512",,,,,,, +COD,19,,"Congo, Dem. Rep.","78,736",,,,,,, +THA,20,,Thailand,"68,864",,,,,,, +FRA,21,,France,"66,896",,,,,,, +GBR,22,,United Kingdom,"65,637",,,,,,, +ITA,23,,Italy,"60,601",,,,,,, +ZAF,24,,South Africa,"55,909",,,,,,, +TZA,25,,Tanzania,"55,572",,,,,,, +MMR,26,,Myanmar,"52,885",,,,,,, +KOR,27,,"Korea, Rep.","51,246",,,,,,, +COL,28,,Colombia,"48,653",,,,,,, +KEN,29,,Kenya,"48,462",,,,,,, +ESP,30,,Spain,"46,444",,,,,,, +UKR,31,,Ukraine,"45,005",,,,,,, +ARG,32,,Argentina,"43,847",,,,,,, +UGA,33,,Uganda,"41,488",,,,,,, +DZA,34,,Algeria,"40,606",,,,,,, +SDN,35,,Sudan,"39,579",,,,,,, +POL,36,,Poland,"37,948",,,,,,, +IRQ,37,,Iraq,"37,203",,,,,,, +CAN,38,,Canada,"36,286",,,,,,, +MAR,39,,Morocco,"35,277",,,,,,, +AFG,40,,Afghanistan,"34,656",,,,,,, +SAU,41,,Saudi Arabia,"32,276",,,,,,, +UZB,42,,Uzbekistan,"31,848",,,,,,, +PER,43,,Peru,"31,774",,,,,,, +VEN,44,,"Venezuela, RB","31,568",,,,,,, +MYS,45,,Malaysia,"31,187",,,,,,, +NPL,46,,Nepal,"28,983",,,,,,, +MOZ,47,,Mozambique,"28,829",,,,,,, +AGO,48,,Angola,"28,813",,,,,,, +GHA,49,,Ghana,"28,207",,,,,,, +YEM,50,,"Yemen, Rep.","27,584",,,,,,, +PRK,51,,"Korea, Dem. People's Rep.","25,369",,,,,,, +MDG,52,,Madagascar,"24,895",,,,,,, +AUS,53,,Australia,"24,127",,,,,,, +CIV,54,,Côte d'Ivoire,"23,696",,,,,,, +CMR,55,,Cameroon,"23,439",,,,,,, +LKA,56,,Sri Lanka,"21,203",,,,,,, +NER,57,,Niger,"20,673",,,,,,, +ROU,58,,Romania,"19,705",,,,,,, +BFA,59,,Burkina Faso,"18,646",,,,,,, +SYR,60,,Syrian Arab Republic,"18,430",,,,,,, +MWI,61,,Malawi,"18,092",,,,,,, +MLI,62,,Mali,"17,995",,,,,,, +CHL,63,,Chile,"17,910",,,,,,, +KAZ,64,,Kazakhstan,"17,797",,,,,,, +NLD,65,,Netherlands,"17,018",,,,,,, +ZMB,66,,Zambia,"16,591",,,,,,, +GTM,67,,Guatemala,"16,582",,,,,,, +ECU,68,,Ecuador,"16,385",,,,,,, +ZWE,69,,Zimbabwe,"16,150",,,,,,, +KHM,70,,Cambodia,"15,762",,,,,,, +SEN,71,,Senegal,"15,412",,,,,,, +TCD,72,,Chad,"14,453",,,,,,, +SOM,73,,Somalia,"14,318",,,,,,, +GIN,74,,Guinea,"12,396",,,,,,, +SSD,75,,South Sudan,"12,231",,,,,,, +RWA,76,,Rwanda,"11,918",,,,,,, +CUB,77,,Cuba,"11,476",,,,,,, +TUN,78,,Tunisia,"11,403",,,,,,, +BEL,79,,Belgium,"11,348",,,,,,, +BOL,80,,Bolivia,"10,888",,,,,,, +BEN,81,,Benin,"10,872",,,,,,, +HTI,82,,Haiti,"10,847",,,,,,, +GRC,83,,Greece,"10,747",,,,,,, +DOM,84,,Dominican Republic,"10,649",,,,,,, +CZE,85,,Czech Republic,"10,562",,,,,,, +BDI,86,,Burundi,"10,524",,,,,,, +PRT,87,,Portugal,"10,325",,,,,,, +SWE,88,,Sweden,"9,903",,,,,,, +HUN,89,,Hungary,"9,818",,,,,,, +AZE,90,,Azerbaijan,"9,762",,,,,,, +BLR,91,,Belarus,"9,507",,,,,,, +JOR,92,,Jordan,"9,456",,,,,,, +ARE,93,,United Arab Emirates,"9,270",,,,,,, +HND,94,,Honduras,"9,113",,,,,,, +AUT,95,,Austria,"8,747",,,,,,, +TJK,96,,Tajikistan,"8,735",,,,,,, +ISR,97,,Israel,"8,547",,,,,,, +CHE,98,,Switzerland,"8,372",,,,,,, +PNG,99,,Papua New Guinea,"8,085",,,,,,, +TGO,100,,Togo,"7,606",,,,,,, +SLE,101,,Sierra Leone,"7,396",,,,,,, +HKG,102,,"Hong Kong SAR, China","7,347",,,,,,, +BGR,103,,Bulgaria,"7,128",,,,,,, +SRB,104,,Serbia,"7,057",,,,,,, +LAO,105,,Lao PDR,"6,758",,,,,,, +PRY,106,,Paraguay,"6,725",,,,,,, +SLV,107,,El Salvador,"6,345",,,,,,, +LBY,108,,Libya,"6,293",,,,,,, +NIC,109,,Nicaragua,"6,150",,,,,,, +KGZ,110,,Kyrgyz Republic,"6,083",,,,,,, +LBN,111,,Lebanon,"6,007",,,,,,, +DNK,112,,Denmark,"5,731",,,,,,, +TKM,113,,Turkmenistan,"5,663",,,,,,, +SGP,114,,Singapore,"5,607",,,,,,, +FIN,115,,Finland,"5,495",,,,,,, +SVK,116,,Slovak Republic,"5,429",,,,,,, +NOR,117,,Norway,"5,233",,,,,,, +COG,118,,"Congo, Rep.","5,126",,,,,,, +CRI,119,,Costa Rica,"4,857",,,,,,, +IRL,120,,Ireland,"4,773",,,,,,, +NZL,121,,New Zealand,"4,693",,,,,,, +LBR,122,,Liberia,"4,614",,,,,,, +CAF,123,,Central African Republic,"4,595",,,,,,, +PSE,124,,West Bank and Gaza,"4,552",,,,,,, +OMN,125,,Oman,"4,425",,,,,,, +MRT,126,,Mauritania,"4,301",,,,,,, +HRV,127,,Croatia,"4,171",,,,,,, +KWT,128,,Kuwait,"4,053",,,,,,, +PAN,129,,Panama,"4,034",,,,,,, +GEO,130,,Georgia,"3,719",a,,,,,, +MDA,131,,Moldova,"3,552",b,,,,,, +BIH,132,,Bosnia and Herzegovina,"3,517",,,,,,, +URY,133,,Uruguay,"3,444",,,,,,, +PRI,134,,Puerto Rico,"3,411",,,,,,, +MNG,135,,Mongolia,"3,027",,,,,,, +ARM,136,,Armenia,"2,925",,,,,,, +JAM,137,,Jamaica,"2,881",,,,,,, +ALB,138,,Albania,"2,876",,,,,,, +LTU,139,,Lithuania,"2,872",,,,,,, +QAT,140,,Qatar,"2,570",,,,,,, +NAM,141,,Namibia,"2,480",,,,,,, +BWA,142,,Botswana,"2,250",,,,,,, +LSO,143,,Lesotho,"2,204",,,,,,, +MKD,144,,"Macedonia, FYR","2,081",,,,,,, +SVN,145,,Slovenia,"2,065",,,,,,, +GMB,146,,"Gambia, The","2,039",,,,,,, +GAB,147,,Gabon,"1,980",,,,,,, +LVA,148,,Latvia,"1,960",,,,,,, +XKX,149,,Kosovo,"1,816",,,,,,, +GNB,150,,Guinea-Bissau,"1,816",,,,,,, +BHR,151,,Bahrain,"1,425",,,,,,, +TTO,152,,Trinidad and Tobago,"1,365",,,,,,, +SWZ,153,,Swaziland,"1,343",,,,,,, +EST,154,,Estonia,"1,316",,,,,,, +TLS,155,,Timor-Leste,"1,269",,,,,,, +MUS,156,,Mauritius,"1,263",,,,,,, +GNQ,157,,Equatorial Guinea,"1,221",,,,,,, +CYP,158,,Cyprus,"1,170",,,,,,, +DJI,159,,Djibouti,942,,,,,,, +FJI,160,,Fiji,899,,,,,,, +BTN,161,,Bhutan,798,,,,,,, +COM,162,,Comoros,796,,,,,,, +GUY,163,,Guyana,773,,,,,,, +MNE,164,,Montenegro,623,,,,,,, +MAC,165,,"Macao SAR, China",612,,,,,,, +SLB,166,,Solomon Islands,599,,,,,,, +LUX,167,,Luxembourg,583,,,,,,, +SUR,168,,Suriname,558,,,,,,, +CPV,169,,Cabo Verde,540,,,,,,, +MLT,170,,Malta,437,,,,,,, +BRN,171,,Brunei Darussalam,423,,,,,,, +MDV,172,,Maldives,417,,,,,,, +BHS,173,,"Bahamas, The",391,,,,,,, +BLZ,174,,Belize,367,,,,,,, +ISL,175,,Iceland,334,,,,,,, +BRB,176,,Barbados,285,,,,,,, +PYF,177,,French Polynesia,280,,,,,,, +NCL,178,,New Caledonia,278,,,,,,, +VUT,179,,Vanuatu,270,,,,,,, +STP,180,,São Tomé and Principe,200,,,,,,, +WSM,181,,Samoa,195,,,,,,, +LCA,182,,St. Lucia,178,,,,,,, +CHI,183,,Channel Islands,165,,,,,,, +GUM,184,,Guam,163,,,,,,, +CUW,185,,Curaçao,160,,,,,,, +KIR,186,,Kiribati,114,,,,,,, +VCT,187,,St. Vincent and the Grenadines,110,,,,,,, +GRD,188,,Grenada,107,,,,,,, +TON,189,,Tonga,107,,,,,,, +FSM,190,,"Micronesia, Fed. Sts.",105,,,,,,, +ABW,191,,Aruba,105,,,,,,, +VIR,192,,Virgin Islands (U.S.),103,,,,,,, +ATG,193,,Antigua and Barbuda,101,,,,,,, +SYC,194,,Seychelles,95,,,,,,, +IMN,195,,Isle of Man,84,,,,,,, +AND,196,,Andorra,77,,,,,,, +DMA,197,,Dominica,74,,,,,,, +BMU,198,,Bermuda,65,,,,,,, +CYM,199,,Cayman Islands,61,,,,,,, +GRL,200,,Greenland,56,,,,,,, +ASM,201,,American Samoa,56,,,,,,, +MNP,202,,Northern Mariana Islands,55,,,,,,, +KNA,203,,St. Kitts and Nevis,55,,,,,,, +MHL,204,,Marshall Islands,53,,,,,,, +FRO,205,,Faroe Islands,49,,,,,,, +SXM,206,,Sint Maarten (Dutch part),40,,,,,,, +MCO,207,,Monaco,38,,,,,,, +LIE,208,,Liechtenstein,38,,,,,,, +TCA,209,,Turks and Caicos Islands,35,,,,,,, +GIB,210,,Gibraltar,34,,,,,,, +SMR,211,,San Marino,33,,,,,,, +MAF,212,,St. Martin (French part),32,,,,,,, +VGB,213,,British Virgin Islands,31,,,,,,, +PLW,214,,Palau,22,,,,,,, +NRU,215,,Nauru,13,,,,,,, +TUV,216,,Tuvalu,11,,,,,,, +,,,,,,,,,,, +WLD,,,World,"7,442,136",,,,,,, +,,,,,,,,,,, +EAS,,,East Asia & Pacific,"2,296,786",,,,,,, +ECS,,,Europe & Central Asia,"911,995",,,,,,, +LCN,,,Latin America & Caribbean,"637,664",,,,,,, +MEA,,,Middle East & North Africa,"436,721",,,,,,, +NAC,,,North America,"359,479",,,,,,, +SAS,,,South Asia,"1,766,383",,,,,,, +SSF,,,Sub-Saharan Africa,"1,033,106",,,,,,, +LIC,,,Low income,"659,273",,,,,,, +LMC,,,Lower middle income,"3,012,924",,,,,,, +UMC,,,Upper middle income,"2,579,910",,,,,,, +HIC,,,High income,"1,190,029",,,,,,, +,,,,,,,,,,, +,a. Excludes Abkhazia and South Ossetia. b. Excludes Transnistria. ,,,,,,,,,, +,,,,,,,,,,, +,http://data.worldbank.org/data-catalog/world-development-indicators,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, diff --git a/Project Write-up and Reflection.pdf b/Project Write-up and Reflection.pdf new file mode 100644 index 0000000..48b38d2 Binary files /dev/null and b/Project Write-up and Reflection.pdf differ diff --git a/README.md b/README.md index 825cba1..b236e2b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ -# InteractiveProgramming +Software Developement - Fall 2017 - Olin College of Engineering - Subeen Kim, John Wen and Victor Bianchi. +This program simulates the game Plague. -This is the base repo for the interactive programming project for Software Design at Olin College. +Please follow the instructions to run the program; +Pygame can be installed from this link: +http://www.pygame.org/news.html +Install pygame with the pip tool in Python 3.6 or greater. + +$ pip install pygame + +Then run the Country.py file with the command: +python Country.py +The game should open and ask the user to press the C key to start. diff --git a/Reflection.pdf b/Reflection.pdf new file mode 100644 index 0000000..bb9a60a Binary files /dev/null and b/Reflection.pdf differ diff --git a/Test Screen.py b/Test Screen.py new file mode 100644 index 0000000..2e4dc73 --- /dev/null +++ b/Test Screen.py @@ -0,0 +1,115 @@ +import pygame + + +background_color = (255,255,255) +RED = (255,0,0) +width, height = 640, 480 + +screen = pygame.display.set_mode((width, height)) +pygame.display.set_caption('Plague Simulation') +screen.fill(background_color) + +pygame.init() + +intro = True + +while intro: + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + quit() + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_c: + intro = False + running = True + if event.key == pygame.K_q: + pygame.quit() + quit() + + + basicfont = pygame.font.SysFont(None, 48) + text = basicfont.render('Welcome To A Plague Simulation!', True, (0, 0, 0), (255, 255, 255)) + textrect = text.get_rect() + textrect.centerx = screen.get_rect().centerx + textrect.centery = screen.get_rect().centery + screen.blit(text, textrect) + + pygame.display.update() + +running = True +while running: + screen.fill(background_color) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + """ circles represent classes for now""" + pygame.draw.circle(screen, RED, (300,200), 38) + pygame.draw.circle(screen, (0,255,0), (150,250),36) + pygame.draw.circle(screen, (0,0,255), (200,350),30) + + pygame.display.update() + +# import os +# import pygame +# +# BLACK = (0, 0, 0) +# RED = (255, 0, 0) +# +# pygame.init() +# font = pygame.font.SysFont('Consolas', 30) +# +# class Ball: +# def __init__(self, x, y, radius=50, color=RED, infected_pop=0, population=2000): +# self.initial_pos = (x, y) +# self.x = x +# self.y = y +# self.color = color +# self.radius = radius +# self.infected_pop = infected_pop +# self.population = population +# +# #def step +# +# def draw(self): +# pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), +# self.radius) +# +# def contains_pt(self, pt): +# x, y = pt +# if not self.x - self.radius < x < self.x + self.radius: +# return False +# if not self.y - self.radius < y < self.y + self.radius: +# return False +# return True +# +# +# screen = pygame.display.set_mode((640, 480)) +# display = 0 +# +# ball1 = Ball(320, 240, radius=80) +# +# balls = [ball1] +# +# running = True +# while running: # forever -- until user clicks in close box +# for event in pygame.event.get(): +# if event.type == pygame.MOUSEBUTTONDOWN: +# for ball in balls: +# if ball.contains_pt(pygame.mouse.get_pos()): +# if ball.infected_pop == 0: +# ball.infected_pop = ball.infected_pop + 1 +# print(ball.infected_pop) +# display = (ball.population) +# if event.type == pygame.QUIT: +# running = False +# +# screen.fill(BLACK) # erases screen +# for ball in balls: +# ball.draw() +# screen.blit(font.render('Total Population:%.2d'%(display) , True, (0, 255, 255)), (0, 440)) +# pygame.display.update() # updates real screen from staged screen +# +# pygame.quit() diff --git a/Time.py b/Time.py new file mode 100644 index 0000000..e0fa6c5 --- /dev/null +++ b/Time.py @@ -0,0 +1,36 @@ +""" + Subeen Kim + Input handling & time +""" +import pygame, time + +pygame.init() +pygame.display.set_mode((400,300)) +pygame.display.set_caption('Mouse Input Test') + +"""pause untile frames_per_sec has passed""" +clock = pygame.time.Clock() +frames_per_sec = 30 + +""" +Input Handling + pygame.event.wait() : sit and block further game execution until an events comes along + pygame.event.poll() : will see whether there are any events wating for processing + pygame.event.get() : returns all of the currently-outstanding events +""" + +playtime = 0 +running = True +while running: + seconds = clock.tick(frames_per_sec)//30 + playtime += seconds + + for event in pygame.event.get(): + if event.type == QUIT: + running = False + if event.type == KEYDOWN and event.key == K_ESCAPE: + running = False + if event.type == MOUSEBUTTONDOWN: + print (event.button) + +pygame.display.quit() diff --git a/UI_Skeleton.py b/UI_Skeleton.py new file mode 100644 index 0000000..6fec354 --- /dev/null +++ b/UI_Skeleton.py @@ -0,0 +1,75 @@ +""" John Wen +Time runs in milliseconds, (1000 = 1 second) +""" + +import pygame +import os + + +BLACK = (0, 0, 0) +RED = (255, 0, 0) +BLUE = (0, 255, 0) + +class Country(): + def __init__(self, pop_infected = 0, x, y, radius, color = RED): + self.pop_infected = pop_infected + self.location = (x, y) + self.radius = radius + self.color = color + + + +pygame.init() + +background_color = (255,255,255) +width, height = 640, 480 + +"""Bunch of variables""" +screen = pygame.display.set_mode((width, height)) +pygame.display.set_caption('Plague Simulation') +screen.fill(background_color) + +UpgradeMenu = pygame.Rect(600,440,40,40) +Timelocation = pygame.Rect(400,0,600,40) +Populationlocation = pygame.Rect(0,440,300,400) +"""Timer""" +Time = 0 +ActiveTime = True +font = pygame.font.SysFont('Consolas', 30) +Population = 125125 +RedCirc = (300,200), 38 + +clock = pygame.time.Clock() + +running = True +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + """ circles represent classes for now""" + pygame.draw.circle(screen, RED, (300,200), 38) + pygame.draw.circle(screen, (0,255,0), (150,250),36) + pygame.draw.circle(screen, (0,0,255), (200,350),30) + """ Black box will be sending you to upgrade screen""" + pygame.draw.rect(screen, (0,0,0), UpgradeMenu) + """Time Display""" + pygame.draw.rect(screen, (0,0,0), Timelocation) + """Country Population Display""" + pygame.draw.rect(screen, (0,0,0), Populationlocation) + """timer display""" + screen.blit(font.render(str(pygame.time.get_ticks()/1000), True, (255, 255, 255)), (400, 0)) + screen.blit(font.render(str(Population), True, (255, 255, 255)), (0, 440)) + + pygame.display.update() + + + if event.type == pygame.MOUSEBUTTONDOWN: + if UpgradeMenu.collidepoint(pygame.mouse.get_pos()): + if pygame.time.get_ticks() > (Time + 1000): + Time = pygame.time.get_ticks() + + # if RedCirc.collidepoint(pygame.mouse.get_pos()): + # if pygame.time.get_ticks() > (Time + 1000): + # Population = 12345 + """ Compare last time clicked""" +pygame.quit() diff --git a/import.py b/import.py new file mode 100644 index 0000000..e69de29 diff --git a/location.py b/location.py new file mode 100644 index 0000000..fcee0ff --- /dev/null +++ b/location.py @@ -0,0 +1,9 @@ +def location(x,y): + x1 = x - 20 + x2 = x + 20 + y1 = y - 20 + y2 = y + 20 + + indication = ImageDraw.Draw(img) + indication.ellipse((x1, y1, x2, y2)) + img.save('newimage2.jpg') diff --git a/rounds.py b/rounds.py new file mode 100644 index 0000000..b1ee326 --- /dev/null +++ b/rounds.py @@ -0,0 +1,23 @@ + +rounds = 0 +number = 0 +print("Would you like to increase transmission, symptoms, or the diseases abilities ?") +round_user_choice = input('Type T, S, A, or hit the space bar to skip\n') +x = 0 +if (round_user_choice == ' '): + print('You have skipped your upgrade for this turn') + +elif(round_user_choice == 'T'): + print("You can upgrade the pathogen's transmission by increasing \n1. airborne \n2. rodent \n3. meat") + number = input('Type 1, 2, or 3 to upgrade a specific one\n') + print ('Round ' + str(rounds) + ' user chose to upgrade T ' + str(number)); +elif(round_user_choice == 'S'): + print("You can upgrade the pathogen's symptoms by increasing \n1. insomnia \n2. necrosis \n3. inflammation") + number = int(input('Type 1, 2, or 3 to upgrade a specific one\n')) + print ('Round ' + str(rounds) + ' user chose to upgrade S ' + str(number)); +elif(round_user_choice == 'A'): + print("You can upgrade the pathogen's abilities by increasing \n1. drug resitance \n2. cold resistance \n3. hereditary") + number = int(input('Type 1, 2, or 3 to upgrade a specific one\n')) + print ('Round ' + str(rounds) + ' user chose to upgrade A ' + str(number)); +else: #other/user error + print('Please try again')