Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- This module creates character build recommendations for
- Dungeon Crawl Stone Soup that give the opportunity to
- win a new species, background, or god.
- The user needs to edit the 'wonSpecies' and 'wonBackgrounds'
- tuple at the top of the module.
- The module outputs four character build combos. The player
- chooses one of these that strikes his fancy, and if the
- game is won it will add a species, background, and/or
- god to the player's winlist.
- The first has an unwon species and a recommended background
- for that species, which may or may not have been won
- already.
- The second has an unwon species and a recommended species
- for that background, which may or may not have been won
- already.
- The third is a recommended combination of won species and
- won background. The player ought to choose an unwon god
- for this combo.
- The fourth is a random pairing of species and background
- without regard for recommendations. If both the species
- and background have already been won, a new god ought to
- be worshipped.
- The module when run will output a certain number of sets of
- four combos, with a certain number of empty circles. These
- latter are to indicate a number of attempts for the chosen
- combo of the four before moving on to the next line. The
- output can be cut and pasted into a word processor to be
- printed.
- '''
- from random import choice
- ##############################
- ## USER: EDIT THESE LINES ##
- ##############################
- ## Edit these tuples to reflect the species and backgrounds you've already won
- wonSpecies = ('Ce','DD','Dg','Ds','Dr','Gr','Gh','Ha','HO','Ko','Mf','Mi',
- 'Sp','Tr','Vp','VS')
- wonBackgrounds = ('Fi','Gl','Mo','Hu','As','Be','AK','En','Cj','FE','IE','EE',
- 'Ar')
- ## Edit these values to set the number of lines to be printed, and the number
- ## of attempts for each line.
- lines = 80
- attempts = 5
- ###################
- ## CODE BEGINS ##
- ###################
- ## These recommendations were harvested from the
- ## character selection screen of 0.21.
- speciesRecs = {'Hu':('Be','Cj','Ne','FE','IE'),
- 'Ba':('Fi','Be','Sk','Su','IE'),
- 'Ce':('Fi','Gl','Hu','Wr','AM'),
- 'DD':('Fi','Hu','Be','Ne','EE'),
- 'DE':('Wz','Cj','Su','Ne','FE','IE','AE','EE','VM'),
- 'Dg':('Tm','Cj','FE','IE','AE','EE'),
- 'Ds':('Gl','Be','AK','Wz','Ne','FE','IE','VM'),
- 'Dr':('Be','Tm','Cj','FE','IE','AE','EE','VM'),
- 'Fe':('Be','Tm','En','Cj','Su','IE','AE','VM'),
- 'Fo':('Fi','Hu','AK','AM','EE','VM'),
- 'Gr':('Fi','Gl','Mo','Be','FE','IE','EE','VM'),
- 'Gh':('Gl','Mo','Wr','Ne','IE','EE'),
- 'Ha':('Fi','Hu','Be','AK','Sk'),
- 'HO':('Fi','Mo','Be','AK','Ne','FE'),
- 'Ko':('Hu','Be','AM','En','Cj','Su'),
- 'Mf':('Gl','Be','Sk','Tm','Su','IE','VM'),
- 'Mi':('Fi','Gl','Mo','Hu','Be','AK'),
- 'Mu':('Wz','Cj','Su','Ne','FE','IE'),
- 'Na':('Be','Tm','Wr','En','Wz','FE','IE','VM'),
- 'Op':('As','Tm','Wz','Cj','FE','IE','EE','VM'),
- 'Og':('Hu','Be','AM','Wz','FE'),
- 'Sp':('As','AK','Wr','En','Cj','EE','VM','Ar'),
- 'Te':('Be','Wz','Cj','Su','FE','AE','VM'),
- 'Tr':('Fi','Mo','Hu','Be','Wr','Wz','EE'),
- 'Vp':('Gl','As','En','Ne','IE','EE'),
- 'VS':('Fi','As','Be','En','Cj','Ne','IE')}
- backgroundRecs = {'Fi':('HO','Mi','Gr','Tr','Ce','DD'),
- 'Gl':('HO','Mi','Mf','Gr','Ce','DD'),
- 'Mo':('HO','Mf','Gr','Tr','Ds','Ce','DD'),
- 'Hu':('HO','Ha','Tr','Ko','Ce','Og'),
- 'As':('Ha','Tr','Ds','Sp','VS','Vp'),
- 'Be':('HO','Mi','Mf','Gr','Ha','Ds','Og'),
- 'AK':('HO','Mf','Dr','Tr','Ds','Sp'),
- 'CK':('HO','Mi','Mf','Dr','Tr','Ds','Ce'),
- 'Sk':('Mf','Dr','Ha','Ce','Vp'),
- 'Tm':('Mf','Dr','Tr','Ds','Dg','Na'),
- 'Wr':('Dr','Ha','Ce','Sp','DD','Fe'),
- 'AM':('Tr','Ko','Ce','Sp','DE','Fo'),
- 'En':('Ko','Sp','DE','Vp','Na','Fe'),
- 'Wz':('Dr','Hu','DE','Na','Op','Mu'),
- 'Cj':('Dr','Te','DE','Dg','Na'),
- 'Su':('HO','Mf','Te','DE','VS','Vp'),
- 'Ne':('HO','Ds','DE','DD','Vp','Mu'),
- 'FE':('HO','Gr','Te','DE','Dg','Na'),
- 'IE':('Mf','Gr','Dr','DE','Dg','Na'),
- 'AE':('Dr','Te','DE','VS','Na'),
- 'EE':('Gr','Gh','Sp','DE','DD','Dg','Op'),
- 'VM':('Mf','Ds','Sp','Te','DE','Na','Fe'),
- 'Ar':('Dr','Ha','Ko','Ds','Sp','DD'),
- 'Wn':('HO','Mf','Dr','Hu','Ds','Ce','Sp')}
- ## Calculate which species and backgrounds still need to be won
- allSpecies = speciesRecs.keys()
- allBackgrounds = backgroundRecs.keys()
- needSpecies = [x for x in allSpecies if x not in wonSpecies]
- needBackgrounds = [x for x in allBackgrounds if x not in wonBackgrounds]
- ## Validate each combo.
- ## Reject forbidden combos: DgBe, DgAK, DgCK, GhTm, MuTm
- ## If both the species and background have been won, the player needs to
- ## be able to worship an unwon god. This means that the species cannot
- ## be Dg, and that the already-won background cannot be a zealot.
- species = lambda combo: combo[:2]
- background = lambda combo: combo[-2:]
- def okay(combo):
- if combo in ('DgBe','DgAK','DgCK','GhTm','MuTm'):
- return False
- s = species(combo)
- b = background(combo)
- if s in wonSpecies and b in wonBackgrounds:
- if s == 'Dg' or b in ('Be','AK','CK'):
- return False
- return True
- ## Select a combo with an unwon species
- def newSpecies():
- while True:
- s = choice(needSpecies)
- b = choice(speciesRecs[s])
- combo = s + b
- if okay(combo):
- return combo
- ## Select a combo with an unwon background
- def newBackground():
- while True:
- b = choice(needBackgrounds)
- s = choice(backgroundRecs[b])
- combo = s + b
- if okay(combo):
- return combo
- ## Select a combo that has a won species and a won background
- ## use a set to handle duplicates from reciprocal recommendations
- doneCombos = set()
- for s in wonSpecies:
- for b in [x for x in wonBackgrounds if x in speciesRecs[s]]:
- combo = s + b
- if okay(combo):
- doneCombos.add(combo)
- for b in wonBackgrounds:
- for s in [x for x in wonSpecies if x in backgroundRecs[b]]:
- combo = s + b
- if okay(combo):
- doneCombos.add(combo)
- ## random.choice will need to be able to index the group
- doneCombos = list(doneCombos)
- def doneCombo():
- return choice(doneCombos)
- ## Select a random combo
- def randomCombo():
- while True:
- s = choice(allSpecies)
- b = choice(allBackgrounds)
- combo = s + b
- if okay(combo):
- return combo
- ## Print a single line of combos.
- ## Make sure that each species and background in the line is unique
- def oneline(m):
- circle = u'\u25ef'
- while True:
- line = [newSpecies(), newBackground(), doneCombo(),randomCombo()]
- if (len(set([species(x) for x in line])) == 4 and
- len(set([background(x) for x in line])) == 4):
- break
- line.extend([circle]*m)
- print ' '.join(line)
- ## Print all the lines
- def alllines(n,m):
- for i in range(n):
- oneline(m)
- if __name__ == '__main__':
- alllines(lines,attempts)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement