Last active
August 29, 2015 13:56
-
-
Save GabLeRoux/8869033 to your computer and use it in GitHub Desktop.
random gamejam styles
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import random | |
import itertools | |
import urllib2 | |
import requests | |
def main(): | |
teams = getTeams("https://docs.google.com/spreadsheet/pub?key=0Aq75s3QIah5hdHhtN0xCTl9kb3VLeWticlJjN05iMUE&output=csv") | |
styles = [ | |
'Platformer', | |
'Shoot’em up', | |
'Hack and slash', | |
'Jeu de rôle', | |
'Tower defense', | |
'Rythmique', | |
'Compétition', | |
'Romance' | |
] | |
combos = getCombos(styles) | |
teamsAndStyles = assignTeamsAndStyles(teams, combos) | |
for team in teamsAndStyles: | |
print team[0], "-->", team[1][0], "+", team[1][1] | |
def getTeams(spreadsheetUrl): | |
''' | |
returns array of teams from published google spreadsheet url (csv) | |
''' | |
response = requests.get(spreadsheetUrl) | |
assert response.status_code == 200, 'Wrong status code: ' + \ | |
str(response.status_code) | |
return [x for x in str(response.content).split("\n")] | |
def getCombos(styles, verbose=True): | |
''' | |
returns a list of all styles combinations without repetitions | |
''' | |
if verbose: | |
print "La liste des styles possibles:" | |
combos = [] | |
tempCombos = itertools.combinations(styles, 2) | |
for combination in tempCombos: | |
combos.append([combination[0], combination[1]]) | |
if verbose: | |
print combination[0], combination[1] | |
if verbose: | |
print "" | |
return combos | |
def assignTeamsAndStyles(teams, combos): | |
''' | |
The great random merge happens here | |
''' | |
teamsAndStyles = [] | |
for team in teams: | |
magicalRandomNumber = random.randint(0, len(combos) - 1) | |
stylesToAssign = combos[magicalRandomNumber] | |
combos.pop(magicalRandomNumber) | |
teamsAndStyles.append([team, stylesToAssign]) | |
return teamsAndStyles | |
if __name__ == '__main__': | |
main() |
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
$ python gamejam-styles.py | |
La liste des styles possibles: | |
Platformer Shoot’em up | |
Platformer Hack and slash | |
Platformer Jeu de rôle | |
Platformer Tower defense | |
Platformer Rythmique | |
Platformer Compétition | |
Platformer Romance | |
Shoot’em up Hack and slash | |
Shoot’em up Jeu de rôle | |
Shoot’em up Tower defense | |
Shoot’em up Rythmique | |
Shoot’em up Compétition | |
Shoot’em up Romance | |
Hack and slash Jeu de rôle | |
Hack and slash Tower defense | |
Hack and slash Rythmique | |
Hack and slash Compétition | |
Hack and slash Romance | |
Jeu de rôle Tower defense | |
Jeu de rôle Rythmique | |
Jeu de rôle Compétition | |
Jeu de rôle Romance | |
Tower defense Rythmique | |
Tower defense Compétition | |
Tower defense Romance | |
Rythmique Compétition | |
Rythmique Romance | |
Compétition Romance | |
sample data to test --> Jeu de rôle + Compétition | |
Glorious rand stuff --> Hack and slash + Compétition | |
Awesome trollers --> Tower defense + Rythmique | |
Magical Hipsters --> Platformer + Compétition | |
Love Machines --> Hack and slash + Romance | |
abhdflhajvdf --> Jeu de rôle + Romance | |
bf29ufb932ufb --> Platformer + Romance | |
fuq349bfuf --> Hack and slash + Jeu de rôle | |
f2983hqoiuf --> Platformer + Rythmique | |
qfo98923fnq --> Platformer + Jeu de rôle | |
3foqnuof39q0823f --> Hack and slash + Rythmique | |
qo23fqu23fihq2 --> Compétition + Romance | |
f3ihqfj23ofu --> Shoot’em up + Rythmique | |
2f38hh35n4h830 --> Shoot’em up + Jeu de rôle | |
adsfdfnif --> Platformer + Hack and slash | |
2hf323f9jq203fj --> Shoot’em up + Romance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment