-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f16c67a
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#the only things you need to change to adapt to new years should be freshman and freshmanhouses | ||
freshmanhouses = {"Zane": "Pforzheimer", "Amari": "Pforzheimer", "Timi": "Pforzheimer", "Simon": "Mather"} | ||
freshman = ["Simon", "Amari", "Timi", "Zane"] | ||
|
||
class player: | ||
def __init__(self, name): | ||
self.name = name | ||
self.guesses = {} | ||
self.score = 0 | ||
|
||
def guess(self, freshman, house): | ||
self.guesses[freshman] = house | ||
|
||
def saveguesses(self, guesses): | ||
for i in range(len(freshman)): | ||
self.guess(freshman[i], house(guesses[i + 3])) | ||
|
||
def getscore(self): | ||
allquad = True | ||
for freshman, house in self.guesses.items(): | ||
realhouse = freshmanhouses[freshman] | ||
if house not in quad: | ||
allquad = False | ||
if house == realhouse: | ||
self.score += 4 | ||
for neighborhood in houseNeighborhoods: | ||
if (realhouse in neighborhood) and (house in neighborhood) and (realhouse != house): | ||
self.score += 1 | ||
if allquad == True: | ||
self.score += 1 | ||
|
||
def house(string): | ||
for neighborhood in houseNeighborhoods: | ||
for house in neighborhood: | ||
if house in string: | ||
return house | ||
return "uh oh" | ||
|
||
quad = ["Pforzheimer", "Currier", "Cabot"] | ||
riverwest = ["Eliot", "Winthrop", "Kirkland"] | ||
square = ["Adams", "Quincy", "Lowell"] | ||
rivereast = ["Dunster", "Leverett", "Mather"] | ||
houseNeighborhoods = [quad, riverwest, square, rivereast] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import csv | ||
from helperfunctions import * | ||
|
||
if __name__ == "__main__": | ||
players = [] | ||
|
||
#get predictions | ||
with open("predictions.csv", mode = "r") as file: | ||
csvFile = csv.reader(file) | ||
next(csvFile) | ||
for line in csvFile: | ||
newplayer = player(line[2]) | ||
newplayer.saveguesses(line) | ||
newplayer.getscore() | ||
players.append(newplayer) | ||
|
||
players.sort(key = lambda x: x.score, reverse = True) | ||
results = [[player.name, player.score] for player in players] | ||
|
||
file = open('results.txt','w') | ||
file.write("Here are the results for the housing game\n") | ||
for i in range(len(results)): | ||
place = results[i] | ||
file.write("Place: " + str(i+1) + ", Player: " + place[0] + ", Score: " + str(place[1]) + "\n") | ||
file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This program is to run the housing game. Rules are as follows, Guessing the correct house nets 4 points, Guessing a house in the correct neighborhood nets 1 point. If you predict all freshman are in the quad, you get a bonus point. | ||
|
||
In order to run this, first create a google survey. Google survey must require email. First question must be name. Then have each person guess what house each freshman is going to get with a dropdown. options must have actual full name of house in them to work (dont put full name in two different options). export as csv | ||
|
||
To adapt to new years, change the freshman in the freshman list. make sure that the freshman in the list are in the same order as was asked in the survey. change freshmanhouses in the helper functions to the houses each freshman got. | ||
|
||
Then running housing.py should create a results file. |