history_generator.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:History-Generator 作者: ReedOei 项目源码 文件源码
def setup(self):
        self.create_gui()

        # Clear out the event log
        with open('event_log.txt', 'w') as f:
            f.write('')

        size = utility.S_WIDTH // utility.CELL_SIZE
        data = noise.generate_noise(size, 'Generating terrain: ')
        print('')
        cells_x = utility.S_WIDTH // utility.CELL_SIZE
        cells_y = utility.S_HEIGHT // utility.CELL_SIZE
        for x in xrange(cells_x):
            self.cells.append([])
            for y in xrange(cells_y):
                utility.show_bar(x * cells_y + y, cells_x * cells_y, message='Generating world: ', number_limit=True)
                self.cells[-1].append(terrain.Cell(self, '', x, y, data[x][y], random.random()**6, 0, None))

        print('')
        self.weather = terrain.Weather(self.cells, self)
        self.weather.run(10)

        for x, row in enumerate(self.cells):
            for y, cell in enumerate(row):
                cell.terrain.setup()
                cell.reset_color()

        print('')

        self.nations = []
        self.religions = []
        self.old_nations = {}

        for new_nation in xrange(self.nation_count):
            self.add_nation(Nation(self))

        # Initially create one new religion for every nation
        for i in xrange(self.nation_count):
            new_religion = Religion(self.nations[i].language, self.nations[i].language.make_name_word())
            new_religion.adherents[self.nations[i].cities[0].name] = self.nations[i].cities[0].population
            self.religions.append(new_religion)

        # Choose a random nation to generate our world's name with
        lang = random.choice(self.nations).language
        self.world_name = lang.translateTo('world')

        self.db = db.DB(self.world_name)
        self.db.setup()

        events.main = self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号