''' 2021-06-04 Having learned The Basics of CIV IV Plot Culture: I have no need for Specific Values # # # Created on May 11, 2018 @author: Brett Paufler Copyright Brett Paufler Simple script determing Plot Culture culture_text: outputs surrounding plot culture given starting parameters and step requirements This is likely a one shot script ''' from collections import namedtuple cultural_level = namedtuple( typename='cultural_level', field_names=['size', 'min_culture', 'name']) cultural_levels = [ cultural_level(1, 0, 'Poor'), cultural_level(2, 10, 'Fledgling'), cultural_level(3, 100, 'Developing'), cultural_level(4, 500, 'Refined'), cultural_level(5, 5000, 'Influential'), cultural_level(6, 50000, 'Legendary') ] class City(object): def __init__(self, cpt, init_culture=0, tiles=None): ''' cpt (int): culture per turn init_culture (int): typical 0, starting culture tiles (list): starting culture of plot tiles''' self.cpt = cpt self.culture = init_culture if tiles: self.tiles else: self.tiles = [0, 0, 0, 0, 0, 0] #City tile and outer ring will be equal self.level = cultural_levels[0] self.assign_level() def assign_level(self): '''Determines current cultural level''' for level in cultural_levels: if self.culture >= level.min_culture: self.level = level def __repr__(self): text = 'CITY: CPT(%d) %s' % ( self.cpt, str(self.tiles)) return text def turn(self): '''Culture is a Digital Formula, Turn Advances a Single Step.''' self.assign_level() new_tiles = [] for n, tile in enumerate(self.tiles, 1): c = tile #print c if self.level.size >= n: c += self.cpt #print c if self.level.size - n > 0: c += 20 * (self.level.size - n) #print c new_tiles.append(c) self.tiles = new_tiles self.culture += self.cpt def culture_test(start=2, inc=0, step=50, loops=10): '''Outputs Plot Tile Culture start (int): starting CPT inc (int): step progressing increase in CPT step (int): how many turns before increasing CPT loops (int): number of loops to run ''' turn_num = 0 c = City(start) for _ in range(loops): for __ in range(step): turn_num += 1 c.turn() print 'Turn %d %s' % (turn_num, c) c.cpt += inc if __name__ == '__main__': print 'First: No Increment' culture_test(start=2, inc=0, step=50, loops=10) print print 'Second: Increment 2' culture_test(start=2, inc=2, step=50, loops=10) print print 'Third: Captured High Output' culture_test(start=0, inc=2, step=5, loops=25) print print 'Fourth: +14 Christian Temple' culture_test(start=14, inc=0, step=5, loops=25)